Syslog use more platform independant.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@3877 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
richard 1999-03-09 06:10:01 +00:00
parent e85feec4a4
commit 3a981b0a5c

View file

@ -42,15 +42,35 @@ NSLog_printf_handler *_NSLog_printf_handler;
static void static void
_NSLog_standard_printf_handler (NSString* message) _NSLog_standard_printf_handler (NSString* message)
{ {
#ifdef HAVE_SYSLOG_H unsigned len = [message length];
const char *txt = [message cString]; char buf[len+1];
if (fputs(txt, stderr) == EOF) [message getCString: buf];
buf[len] = '\0';
#ifdef HAVE_SYSLOG_H
if (write(2, buf, len) != len)
{ {
syslog(LOG_INFO, "%s", txt); int mask;
#ifdef LOG_ERR
mask = LOG_ERR;
#else
# ifdef LOG_ERROR
mask = LOG_ERROR;
# else
#include <Help, I can't find a logging levl for syslog>
# endif
#endif
#ifdef LOG_USER
mask |= LOG_USER;
#endif
syslog(mask, "%s", buf);
} }
#else #else
fputs([message cString], stderr); write(2, buf, len);
#endif #endif
} }