Improve mingw logging.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@21538 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2005-07-25 16:23:35 +00:00
parent 5671b24ffd
commit a6d1de2e02
2 changed files with 33 additions and 0 deletions

View file

@ -6,6 +6,7 @@
* Source/NSObject.m: ([conformsToProtocol:]) return NO if passed nul.
* Source/NSBundle.m: be more tolerant.
* Source/objc-load.m: Implemented objc_get_symbol_path() for windows.
* Source/NSLog.m: On mingw write to debugger and event viewer.
2005-07-24 Richard Frith-Macdonald <rfm@gnu.org>

View file

@ -140,6 +140,38 @@ _NSLog_standard_printf_handler (NSString* message)
}
#else
write(_NSLogDescriptor, buf, len);
#ifdef WIN32
{
char *null_terminated_buf = objc_malloc (sizeof (char) * (len + 1));
strncpy (null_terminated_buf, buf, len);
null_terminated_buf[len] = '\0';
OutputDebugString(null_terminated_buf);
if (!IsDebuggerPresent())
{
static HANDLE eventloghandle = 0;
if (!eventloghandle)
{
eventloghandle = RegisterEventSource(NULL,
[[[NSProcessInfo processInfo] processName] cString]);
}
if (eventloghandle)
{
ReportEvent(eventloghandle, // event log handle
EVENTLOG_WARNING_TYPE, // event type
0, // category zero
0, // event identifier
NULL, // no user security identifier
1, // one substitution string
0, // no data
&null_terminated_buf, // pointer to string array
NULL); // pointer to data
}
}
objc_free (null_terminated_buf);
}
#endif // WIN32
#endif
}