asdasdfweqd23rf2f32
asdasdfweqd23rf2f32

Reputation: 31

remove timestamp and process id

I use code for show user number in debug. How to remove in only debug line 2016-08-20 13:02:52.773 1[37441:2806628]

for (int i=0; i<100; i++) 
{ 
    NSLog(@"user %d", i);
}

in debug I want to get

user1 
user2
user3 

and etc

But get this

2016-08-20 13:02:52.773 1[37441:2806628] user1
2016-08-20 13:02:52.773 1[37441:2806628] user2
2016-08-20 13:02:52.773 1[37441:2806628] user3

How I can remove this lines

2016-08-20 13:02:52.773 1[37441:2806628] 
2016-08-20 13:02:52.773 1[37441:2806628]
2016-08-20 13:02:52.773 1[37441:2806628]

Upvotes: 2

Views: 293

Answers (3)

Bhavin Ramani
Bhavin Ramani

Reputation: 3219

Use printf instead of NSLog:

for (int i=0; i<100; i++) 
 { 
   printf("User=%d\n",i); //Here \n is for new line
 }

Difference between NSLog and Printf statement for ObjectiveC

Upvotes: 1

Ketan Parmar
Ketan Parmar

Reputation: 27438

Use printf instead of NSLog. Because NSLog prints logs like time stamp and other details like process name.

If you want every word in new line then add \n in printf function.

There are basic major difference between printf and NSLog but this is beyond the requirement that asked in question. so, as you asked that you don't want timestamp and process id then you should use printf instead of NSLog. That's it!!

Upvotes: 1

Nirav D
Nirav D

Reputation: 72450

For that you need to use printf function instead of NSLog like this because NSLog also print project name and timestamp with it.

for (int i=0; i<5; i++)
{
    printf("\nUser %d",i);
}

Note: printf also used to print the formatted sting just like we used in c language also you need to use \n to set every print statement in new line.

Upvotes: 0

Related Questions