Mercurial > noffle
view src/log.c @ 54:125d79c9e586 noffle
[svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
src/database.c, src/dynamicstring.c, src/fetch.c, src/fetchlist.c,
src/group.c, src/itemlist.c, src/lock.c, src/log.c, src/noffle.c,
src/online.c, src/outgoing.c, src/over.c, src/post.c, src/protocol.c,
src/pseudo.c, src/request.c, src/server.c, src/util.c:
Added portable.h #include.
* src/client.h, src/database.h, src/fetch.c, src/group.h, src/lock.c,
src/outgoing.c, src/over.c, src/over.h, src/pseudo.c, src/server.c,
src/util.c, src/util.h: Added some #ifdefs to correctly include either
time.h or sys/time.h or both, depending on which are found.
* src/noffle.c: Changed the return-type of the signal-handlers bugReport()
and logSignal() to RETSIGTYPE, which is either void or int, depending on
the system you compile on (autoconf #defines the RETSIGTYPE).
author | uh1763 |
---|---|
date | Tue, 09 May 2000 23:28:38 +0100 |
parents | 32ba1198c6fa |
children | c874bd3c4bb8 |
line wrap: on
line source
/* log.c $Id: log.c 60 2000-05-09 22:28:38Z uh1763 $ */ #if HAVE_CONFIG_H #include <config.h> #endif #include <syslog.h> #include <stdarg.h> #include "common.h" #include "log.h" #include "portable.h" #define MAXLENGTH 240 struct { Bool interactive; } log = { FALSE }; void Log_init( Str name, Bool interactive, int facility ) { int option = LOG_PID | LOG_CONS; log.interactive = interactive; openlog( name, option, facility ); } #define DO_LOG( LEVEL ) \ va_list ap; \ Str t; \ \ va_start( ap, fmt ); \ vsnprintf( t, MAXCHAR, fmt, ap ); \ if ( MAXLENGTH < MAXCHAR ) \ t[ MAXLENGTH ] = '\0'; \ syslog( LEVEL, "%s", t ); \ if ( log.interactive ) \ fprintf( stderr, "%s\n", t ); \ va_end( ap ); void Log_inf( const char *fmt, ... ) { DO_LOG( LOG_INFO ); } void Log_err( const char *fmt, ... ) { DO_LOG( LOG_ERR ); } /* Ensure the condition "cond" is true; otherwise log an error and return 1 */ int Log_check(int cond, const char *fmt, ... ) { if (!cond) { DO_LOG( LOG_ERR ); return 1; } return 0; } void Log_ntc( const char *fmt, ... ) { DO_LOG( LOG_NOTICE ); } void Log_dbg( const char *fmt, ... ) { #ifdef DEBUG DO_LOG( LOG_DEBUG ); #endif }