mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 16:50:58 +00:00
Minor enhancement to improve debugging
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@20775 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
db7b22a4fb
commit
2defc1af93
6 changed files with 61 additions and 8 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2005-02-22 14:00 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Documentation/Base.gsdoc:
|
||||||
|
* Source/GSPrivate.h:
|
||||||
|
* Source/NSDebug.m:
|
||||||
|
* Source/NSLog.m:
|
||||||
|
* Source/NSUserDefaults.m:
|
||||||
|
Add GSLogThread to include thread id in NSLog() and debug output.
|
||||||
|
|
||||||
2005-02-22 11:12 Richard Frith-Macdonald <rfm@gnu.org>
|
2005-02-22 11:12 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/GSFFCallInvocation.m:
|
* Source/GSFFCallInvocation.m:
|
||||||
|
|
|
@ -104,6 +104,15 @@
|
||||||
some reason.
|
some reason.
|
||||||
</p>
|
</p>
|
||||||
</desc>
|
</desc>
|
||||||
|
<term>GSLogThread</term>
|
||||||
|
<desc>
|
||||||
|
<p>
|
||||||
|
Setting the user default <code>GSLogThread</code> to
|
||||||
|
<code>YES</code> will cause NSLog and debug output to
|
||||||
|
include the current thread in the logged message.<br />
|
||||||
|
This is useful for debugging multi-threaded applications.
|
||||||
|
</p>
|
||||||
|
</desc>
|
||||||
<term>GSMacOSXCompatible</term>
|
<term>GSMacOSXCompatible</term>
|
||||||
<desc>
|
<desc>
|
||||||
<p>
|
<p>
|
||||||
|
|
|
@ -167,6 +167,7 @@ typedef enum {
|
||||||
GSMacOSXCompatible, // General behavior flag.
|
GSMacOSXCompatible, // General behavior flag.
|
||||||
GSOldStyleGeometry, // Control geometry string output.
|
GSOldStyleGeometry, // Control geometry string output.
|
||||||
GSLogSyslog, // Force logging to go to syslog.
|
GSLogSyslog, // Force logging to go to syslog.
|
||||||
|
GSLogThread, // Include thread ID in log message.
|
||||||
NSWriteOldStylePropertyLists, // Control PList output.
|
NSWriteOldStylePropertyLists, // Control PList output.
|
||||||
GSUserDefaultMaxFlag // End marker.
|
GSUserDefaultMaxFlag // End marker.
|
||||||
} GSUserDefaultFlagType;
|
} GSUserDefaultFlagType;
|
||||||
|
|
|
@ -621,7 +621,7 @@ _GSDebugAllocationListAll(void)
|
||||||
void
|
void
|
||||||
GSDebugAllocationRemove(Class c, id o)
|
GSDebugAllocationRemove(Class c, id o)
|
||||||
{
|
{
|
||||||
(*_GSDebugAllocationRemoveFunc)(c,o);
|
(*_GSDebugAllocationRemoveFunc)(c,o);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include "Foundation/NSLock.h"
|
#include "Foundation/NSLock.h"
|
||||||
#include "Foundation/NSAutoreleasePool.h"
|
#include "Foundation/NSAutoreleasePool.h"
|
||||||
#include "Foundation/NSData.h"
|
#include "Foundation/NSData.h"
|
||||||
|
#include "Foundation/NSThread.h"
|
||||||
|
|
||||||
#ifdef HAVE_SYSLOG_H
|
#ifdef HAVE_SYSLOG_H
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
|
@ -46,6 +47,8 @@
|
||||||
|
|
||||||
#include "GSPrivate.h"
|
#include "GSPrivate.h"
|
||||||
|
|
||||||
|
extern NSThread *GSCurrentThread();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A variable holding the file descriptor to which NSLogv() messages are
|
* A variable holding the file descriptor to which NSLogv() messages are
|
||||||
* written by default. GNUstep initialises this to stderr.<br />
|
* written by default. GNUstep initialises this to stderr.<br />
|
||||||
|
@ -211,6 +214,12 @@ NSLog (NSString* format, ...)
|
||||||
* ensuring that a newline is present at the end of the message.
|
* ensuring that a newline is present at the end of the message.
|
||||||
* </p>
|
* </p>
|
||||||
* <p>
|
* <p>
|
||||||
|
* In GNUstep, the GSLogThread user default may be set to YES in
|
||||||
|
* order to instruct this function to include the internal ID of
|
||||||
|
* the mcurrent thread after the process ID. This can help you
|
||||||
|
* to track the behavior of a multi-threaded program.
|
||||||
|
* </p>
|
||||||
|
* <p>
|
||||||
* The resulting message is then passed to a handler function to
|
* The resulting message is then passed to a handler function to
|
||||||
* perform actual output. Locking is performed around the call to
|
* perform actual output. Locking is performed around the call to
|
||||||
* the function actually writing the message out, to ensure that
|
* the function actually writing the message out, to ensure that
|
||||||
|
@ -242,15 +251,38 @@ NSLogv (NSString* format, va_list args)
|
||||||
|
|
||||||
#ifdef HAVE_SYSLOG
|
#ifdef HAVE_SYSLOG
|
||||||
if (GSUserDefaultsFlag(GSLogSyslog) == YES)
|
if (GSUserDefaultsFlag(GSLogSyslog) == YES)
|
||||||
prefix = @"";
|
{
|
||||||
|
if (GSUserDefaultsFlag(GSLogThread) == YES)
|
||||||
|
{
|
||||||
|
prefix = [NSString stringWithFormat: @"[%08x] ", GSCurrentThread()];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
prefix = @"";
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
prefix = [NSString
|
{
|
||||||
stringWithFormat: @"%@ %@[%d] ",
|
if (GSUserDefaultsFlag(GSLogThread) == YES)
|
||||||
[[NSCalendarDate calendarDate]
|
{
|
||||||
descriptionWithCalendarFormat: @"%Y-%m-%d %H:%M:%S.%F"],
|
prefix = [NSString
|
||||||
[[NSProcessInfo processInfo] processName],
|
stringWithFormat: @"%@ %@[%d,%08x] ",
|
||||||
pid];
|
[[NSCalendarDate calendarDate]
|
||||||
|
descriptionWithCalendarFormat: @"%Y-%m-%d %H:%M:%S.%F"],
|
||||||
|
[[NSProcessInfo processInfo] processName],
|
||||||
|
pid, GSCurrentThread()];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
prefix = [NSString
|
||||||
|
stringWithFormat: @"%@ %@[%d] ",
|
||||||
|
[[NSCalendarDate calendarDate]
|
||||||
|
descriptionWithCalendarFormat: @"%Y-%m-%d %H:%M:%S.%F"],
|
||||||
|
[[NSProcessInfo processInfo] processName],
|
||||||
|
pid];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Check if there is already a newline at the end of the format */
|
/* Check if there is already a newline at the end of the format */
|
||||||
if (![format hasSuffix: @"\n"])
|
if (![format hasSuffix: @"\n"])
|
||||||
|
|
|
@ -121,6 +121,8 @@ static void updateCache(NSUserDefaults *self)
|
||||||
= [self boolForKey: @"GSOldStyleGeometry"];
|
= [self boolForKey: @"GSOldStyleGeometry"];
|
||||||
flags[GSLogSyslog]
|
flags[GSLogSyslog]
|
||||||
= [self boolForKey: @"GSLogSyslog"];
|
= [self boolForKey: @"GSLogSyslog"];
|
||||||
|
flags[GSLogThread]
|
||||||
|
= [self boolForKey: @"GSLogThread"];
|
||||||
flags[NSWriteOldStylePropertyLists]
|
flags[NSWriteOldStylePropertyLists]
|
||||||
= [self boolForKey: @"NSWriteOldStylePropertyLists"];
|
= [self boolForKey: @"NSWriteOldStylePropertyLists"];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue