mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-25 17:51:01 +00:00
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:
parent
e85feec4a4
commit
3a981b0a5c
1 changed files with 25 additions and 5 deletions
|
@ -42,15 +42,35 @@ NSLog_printf_handler *_NSLog_printf_handler;
|
|||
static void
|
||||
_NSLog_standard_printf_handler (NSString* message)
|
||||
{
|
||||
#ifdef HAVE_SYSLOG_H
|
||||
const char *txt = [message cString];
|
||||
unsigned len = [message length];
|
||||
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
|
||||
fputs([message cString], stderr);
|
||||
write(2, buf, len);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue