Bring NSLog up to spec.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@3876 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 1999-03-09 05:55:19 +00:00
parent edfce95a0f
commit 76d15690ea
5 changed files with 727 additions and 447 deletions

View file

@ -1,3 +1,10 @@
Tue Mar 9 5:16:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* configure.in: Added tests for syslog
* Source/include/config.h.in: Added definitions for syslog
* Source/NSLog.m: Added locking for multi-thread serialisation and
added syslog support when write to stderr fails.
1999-03-08 Adam Fedor <fedor@gnu.org>
* Merged dawn branch to main.

View file

@ -90,6 +90,10 @@
/* Define if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define if you have the <syslog.h> header file. */
#undef HAVE_SYSLOG_H
#undef HAVE_SYSLOG
/* Define if you have the <sys/dir.h> header file. */
#undef HAVE_SYS_DIR_H

View file

@ -26,8 +26,13 @@
#include <Foundation/NSDate.h>
#include <Foundation/NSException.h>
#include <Foundation/NSProcessInfo.h>
#include <Foundation/NSLock.h>
#include <Foundation/NSAutoreleasePool.h>
#ifdef HAVE_SYSLOG_H
#include <syslog.h>
#endif
#ifndef __WIN32__
#include <unistd.h>
#endif
@ -37,7 +42,16 @@ NSLog_printf_handler *_NSLog_printf_handler;
static void
_NSLog_standard_printf_handler (NSString* message)
{
fputs ([message cString], stderr);
#ifdef HAVE_SYSLOG_H
const char *txt = [message cString];
if (fputs(txt, stderr) == EOF)
{
syslog(LOG_INFO, "%s", txt);
}
#else
fputs([message cString], stderr);
#endif
}
void
@ -53,9 +67,12 @@ NSLog (NSString* format, ...)
void
NSLogv (NSString* format, va_list args)
{
NSAutoreleasePool *arp = [NSAutoreleasePool new];
NSString* prefix;
NSString* message;
static NSRecursiveLock *myLock = nil;
NSAutoreleasePool *arp;
NSString *prefix;
NSString *message;
arp = [NSAutoreleasePool new];
if (_NSLog_printf_handler == NULL)
_NSLog_printf_handler = *_NSLog_standard_printf_handler;
@ -73,7 +90,22 @@ NSLogv (NSString* format, va_list args)
message = [NSString stringWithFormat: format arguments: args];
prefix = [prefix stringByAppendingString: message];
if (myLock == nil)
{
[gnustep_global_lock lock];
if (myLock == nil)
{
myLock = [NSRecursiveLock new];
}
[gnustep_global_lock unlock];
}
[myLock lock];
_NSLog_printf_handler (prefix);
[myLock unlock];
[arp release];
}

1116
configure vendored

File diff suppressed because it is too large Load diff

View file

@ -436,6 +436,12 @@ if test $ac_cv_header_sys_socket_h = no -o $ac_cv_header_netinet_in_h = no ; the
AC_MSG_ERROR(Could not find headers needed by class SocketPort)
fi
#--------------------------------------------------------------------
# These headers/functions needed by NSLog.m
#--------------------------------------------------------------------
AC_CHECK_HEADERS(syslog.h)
AC_CHECK_FUNCS(syslog)
#--------------------------------------------------------------------
# This function needed by StdioStream.m
#--------------------------------------------------------------------
@ -471,6 +477,7 @@ AC_CHECK_FUNCS(times)
#--------------------------------------------------------------------
# These functions needed by NSData.m
#--------------------------------------------------------------------
AC_CHECK_FUNCS(mkstemp)
AC_CHECK_FUNCS(shmctl)
AC_CHECK_FUNCS(mmap)
AC_CHECK_FUNCS(mkstemp)