mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Add GSLogOffset to include time zone offset in NSLog output
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@38018 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
7f07159bf0
commit
5f7c695d35
5 changed files with 41 additions and 7 deletions
|
@ -1,3 +1,9 @@
|
|||
2014-07-28 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSUserDefaults.m:
|
||||
* Source/GSPrivate.h:
|
||||
* Source/NSLog.m:
|
||||
|
||||
2014-07-25 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/Tools/gdomap.c: Unless running on windows, allow new -j
|
||||
|
|
|
@ -149,6 +149,17 @@ notice and this notice are preserved.
|
|||
event log.
|
||||
</p>
|
||||
</desc>
|
||||
<term>GSLogOffset</term>
|
||||
<desc>
|
||||
<p>
|
||||
Setting the user default <code>GSLogOffset</code> to
|
||||
<code>YES</code> will cause NSLog and debug output to
|
||||
include the current time zone offset in the timestamp
|
||||
of the logged message.<br />
|
||||
This is useful when comparing logs from machines in
|
||||
different countries.
|
||||
</p>
|
||||
</desc>
|
||||
<term>GSLogThread</term>
|
||||
<desc>
|
||||
<p>
|
||||
|
|
|
@ -236,6 +236,7 @@ typedef enum {
|
|||
GSOldStyleGeometry, // Control geometry string output.
|
||||
GSLogSyslog, // Force logging to go to syslog.
|
||||
GSLogThread, // Include thread ID in log message.
|
||||
GSLogOffset, // Include time zone offset in message.
|
||||
NSWriteOldStylePropertyLists, // Control PList output.
|
||||
GSUserDefaultMaxFlag // End marker.
|
||||
} GSUserDefaultFlagType;
|
||||
|
|
|
@ -40,8 +40,9 @@
|
|||
#ifdef HAVE_SYSLOG_H
|
||||
#include <syslog.h>
|
||||
#elif HAVE_SYS_SLOG_H
|
||||
// we are on a QNX-ish system, which has a syslog symbol somewhere, but it isn't
|
||||
// our syslog function (we use slogf().)
|
||||
/* we are on a QNX-ish system, which has a syslog symbol somewhere,
|
||||
* but it isn't our syslog function (we use slogf().)
|
||||
*/
|
||||
# ifdef HAVE_SYSLOG
|
||||
# undef HAVE_SYSLOG
|
||||
# endif
|
||||
|
@ -303,7 +304,11 @@ NSLog(NSString* format, ...)
|
|||
* In GNUstep, the GSLogThread user default may be set to YES in
|
||||
* order to instruct this function to include the internal ID of
|
||||
* the current thread after the process ID. This can help you
|
||||
* to track the behavior of a multi-threaded program.
|
||||
* to track the behavior of a multi-threaded program.<br />
|
||||
* Also the GSLogOffset user default may be set to YES in order
|
||||
* to instruct this function to include the time zone offset in
|
||||
* the timestamp it logs (good when examining debug logs from
|
||||
* systems running in different countries).
|
||||
* </p>
|
||||
* <p>
|
||||
* The resulting message is then passed to a handler function to
|
||||
|
@ -356,12 +361,22 @@ NSLogv(NSString* format, va_list args)
|
|||
else
|
||||
#endif
|
||||
{
|
||||
NSString *fmt;
|
||||
|
||||
if (GSPrivateDefaultsFlag(GSLogOffset) == YES)
|
||||
{
|
||||
fmt = @"%Y-%m-%d %H:%M:%S.%F %z";
|
||||
}
|
||||
else
|
||||
{
|
||||
fmt = @"%Y-%m-%d %H:%M:%S.%F";
|
||||
}
|
||||
|
||||
if (GSPrivateDefaultsFlag(GSLogThread) == YES)
|
||||
{
|
||||
prefix = [NSString
|
||||
stringWithFormat: @"%@ %@[%d,%"PRIxPTR"x] ",
|
||||
[[NSCalendarDate calendarDate]
|
||||
descriptionWithCalendarFormat: @"%Y-%m-%d %H:%M:%S.%F"],
|
||||
[[NSCalendarDate calendarDate] descriptionWithCalendarFormat: fmt],
|
||||
[[NSProcessInfo processInfo] processName],
|
||||
pid, (NSUInteger)GSCurrentThread()];
|
||||
}
|
||||
|
@ -369,8 +384,7 @@ NSLogv(NSString* format, va_list args)
|
|||
{
|
||||
prefix = [NSString
|
||||
stringWithFormat: @"%@ %@[%d] ",
|
||||
[[NSCalendarDate calendarDate]
|
||||
descriptionWithCalendarFormat: @"%Y-%m-%d %H:%M:%S.%F"],
|
||||
[[NSCalendarDate calendarDate] descriptionWithCalendarFormat: fmt],
|
||||
[[NSProcessInfo processInfo] processName],
|
||||
pid];
|
||||
}
|
||||
|
|
|
@ -252,6 +252,8 @@ updateCache(NSUserDefaults *self)
|
|||
= [self boolForKey: @"GSLogSyslog"];
|
||||
flags[GSLogThread]
|
||||
= [self boolForKey: @"GSLogThread"];
|
||||
flags[GSLogOffset]
|
||||
= [self boolForKey: @"GSLogOffset"];
|
||||
flags[NSWriteOldStylePropertyLists]
|
||||
= [self boolForKey: @"NSWriteOldStylePropertyLists"];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue