Author: rfm
Date: Mon Jul 28 16:40:29 2014
New Revision: 38018

URL: http://svn.gna.org/viewcvs/gnustep?rev=38018&view=rev
Log:
Add GSLogOffset to include time zone offset in NSLog output

Modified:
    libs/base/trunk/ChangeLog
    libs/base/trunk/Documentation/Base.gsdoc
    libs/base/trunk/Source/GSPrivate.h
    libs/base/trunk/Source/NSLog.m
    libs/base/trunk/Source/NSUserDefaults.m

Modified: libs/base/trunk/ChangeLog
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/ChangeLog?rev=38018&r1=38017&r2=38018&view=diff
==============================================================================
--- libs/base/trunk/ChangeLog   (original)
+++ libs/base/trunk/ChangeLog   Mon Jul 28 16:40:29 2014
@@ -1,3 +1,9 @@
+2014-07-28  Richard Frith-Macdonald <[email protected]>
+
+       * Source/NSUserDefaults.m:
+       * Source/GSPrivate.h:
+       * Source/NSLog.m:
+
 2014-07-25  Richard Frith-Macdonald <[email protected]>
 
        * Source/Tools/gdomap.c: Unless running on windows, allow new -j

Modified: libs/base/trunk/Documentation/Base.gsdoc
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Documentation/Base.gsdoc?rev=38018&r1=38017&r2=38018&view=diff
==============================================================================
--- libs/base/trunk/Documentation/Base.gsdoc    (original)
+++ libs/base/trunk/Documentation/Base.gsdoc    Mon Jul 28 16:40:29 2014
@@ -149,6 +149,17 @@
                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>

Modified: libs/base/trunk/Source/GSPrivate.h
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Source/GSPrivate.h?rev=38018&r1=38017&r2=38018&view=diff
==============================================================================
--- libs/base/trunk/Source/GSPrivate.h  (original)
+++ libs/base/trunk/Source/GSPrivate.h  Mon Jul 28 16:40:29 2014
@@ -236,6 +236,7 @@
   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;

Modified: libs/base/trunk/Source/NSLog.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Source/NSLog.m?rev=38018&r1=38017&r2=38018&view=diff
==============================================================================
--- libs/base/trunk/Source/NSLog.m      (original)
+++ libs/base/trunk/Source/NSLog.m      Mon Jul 28 16:40:29 2014
@@ -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 @@
  *   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 @@
   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 @@
        {
          prefix = [NSString
            stringWithFormat: @"%@ %@[%d] ",
-           [[NSCalendarDate calendarDate]
-             descriptionWithCalendarFormat: @"%Y-%m-%d %H:%M:%S.%F"],
+           [[NSCalendarDate calendarDate] descriptionWithCalendarFormat: fmt],
            [[NSProcessInfo processInfo] processName],
            pid];
        }

Modified: libs/base/trunk/Source/NSUserDefaults.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Source/NSUserDefaults.m?rev=38018&r1=38017&r2=38018&view=diff
==============================================================================
--- libs/base/trunk/Source/NSUserDefaults.m     (original)
+++ libs/base/trunk/Source/NSUserDefaults.m     Mon Jul 28 16:40:29 2014
@@ -252,6 +252,8 @@
        = [self boolForKey: @"GSLogSyslog"];
       flags[GSLogThread]
        = [self boolForKey: @"GSLogThread"];
+      flags[GSLogOffset]
+       = [self boolForKey: @"GSLogOffset"];
       flags[NSWriteOldStylePropertyLists]
        = [self boolForKey: @"NSWriteOldStylePropertyLists"];
     }


_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs

Reply via email to