don't print log messages below a certain priority

This commit is contained in:
ehouse 2005-10-30 05:10:26 +00:00
parent f6f5e6eaf0
commit ae4821d5f5
2 changed files with 20 additions and 19 deletions

View file

@ -59,29 +59,28 @@
#include "timermgr.h" #include "timermgr.h"
#include "permid.h" #include "permid.h"
#define N_WORKER_THREADS 5
#define MILLIS 1000
void void
logf( XW_LogLevel level, const char* format, ... ) logf( XW_LogLevel level, const char* format, ... )
{ {
FILE* where = stderr; if ( level <= XW_LOGINFO ) {
struct tm* timp; FILE* where = stderr;
struct timeval tv; struct tm* timp;
struct timezone tz; struct timeval tv;
gettimeofday( &tv, &tz ); struct timezone tz;
timp = localtime( &tv.tv_sec ); gettimeofday( &tv, &tz );
timp = localtime( &tv.tv_sec );
pthread_t me = pthread_self(); pthread_t me = pthread_self();
fprintf( where, "<%lx>%d:%d:%d: ", me, timp->tm_hour, timp->tm_min, fprintf( where, "<%lx>%d:%d:%d: ", me, timp->tm_hour, timp->tm_min,
timp->tm_sec ); timp->tm_sec );
va_list ap; va_list ap;
va_start( ap, format ); va_start( ap, format );
vfprintf( where, format, ap ); vfprintf( where, format, ap );
va_end(ap); va_end(ap);
fprintf( where, "\n" ); fprintf( where, "\n" );
}
} /* logf */ } /* logf */
static int static int

View file

@ -8,8 +8,10 @@
typedef unsigned char HostID; typedef unsigned char HostID;
typedef enum { typedef enum {
XW_LOGINFO XW_LOGERROR
,XW_LOGERROR ,XW_LOGINFO
,XW_LOGVERBOSE0
,XW_LOGVERBOSE1
} XW_LogLevel; } XW_LogLevel;
void logf( XW_LogLevel level, const char* format, ... ); void logf( XW_LogLevel level, const char* format, ... );