discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSLog suggestion


From: Richard Frith-Macdonald
Subject: Re: NSLog suggestion
Date: Fri, 20 Feb 2015 19:48:31 +0000

On 20 Feb 2015, at 19:32, Amr Aboelela <amraboelela@gmail.com> wrote:
> 
> NSLogv(NSString* format, va_list args)
> 
> ...
> 
>             /*prefix = [NSString
> 
>                       stringWithFormat: @"%@ %@[%d] ",
> 
>                       [[NSCalendarDate calendarDate]
> 
>                        descriptionWithCalendarFormat: @"%Y-%m-%d 
> %H:%M:%S.%F"],
> 
>                       [[NSProcessInfo processInfo] processName],
> 
>                       pid];*/
> 
>             prefix = [NSString
> 
>                       stringWithFormat: @"%@ %@[%d-%x] ",
> 
>                       [[NSCalendarDate calendarDate] 
> descriptionWithCalendarFormat: @"%M:%S.%F"],
> 
>                       [[NSProcessInfo processInfo] processName],
> 
>                       pid, (unsigned int)pthread_self()];
> 
> ...
> 
> }
> 
> 
> Instead of printing today date and hour which is useless for a developer, 
> print the current thread id:  (unsigned int)pthread_self()

Well, the timestamp is highly useful for most people, but perhpas more 
importantly we try to be compatible with Apple's implementation.

However, there's a user default called GSLogThread (near the start of the base 
library documentation ... you can find it online at 
http://www.gnustep.org/resources/documentation/Developer/Base/Reference/index.html),
 which you can set to extend the normal log format with a thread ID.  This is 
quite useful for debugging multithreaded programs.

In addition, if you look at NSLog() in your local base library documentation, 
you will find a whole selection of things you can use to customise NSLog() 
behavior and also support various formas of debug logging.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]