Mercurial > noffle
changeset 185:fed1334d766b noffle
[svn] * src/client.c: Change variable only used on constant to 'const'.
* src/filter.c: Add a couple of 'return's after ASSERT() to remove
compiler warnings about functions needing returns.
* NEWS,TODO,configure,configure.in,noffle.conf.example,docs/NOTES,
docs/noffle.conf.5,src/client.c,src/configfile.c,src/content.c,
src/control.c,src/database.c,src/fetch.c,src/fetchlist.c,src/filter.c,
src/group.c,src/lock.c,src/log.c,src/log.h,src/noffle.c,src/outgoing.c,
src/post.c,src/protocol.c,src/request.c,src/server.c,src/util.c:
Debug logging is always compiled and selected via noffle.conf. All debug
logs are classified as all, none, config, control, expire, fetch,
filter, newsbase, noffle, post, protocol, requests and server.
author | bears |
---|---|
date | Sun, 05 Aug 2001 09:24:22 +0100 |
parents | 9854ea5f295f |
children | 7d1f26e7c728 |
files | ChangeLog NEWS TODO configure configure.in docs/NOTES docs/noffle.conf.5 noffle.conf.example src/client.c src/configfile.c src/content.c src/control.c src/database.c src/fetch.c src/fetchlist.c src/filter.c src/group.c src/lock.c src/log.c src/log.h src/noffle.c src/outgoing.c src/post.c src/protocol.c src/request.c src/server.c src/util.c |
diffstat | 27 files changed, 295 insertions(+), 148 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Tue Jun 19 11:23:43 2001 +0100 +++ b/ChangeLog Sun Aug 05 09:24:22 2001 +0100 @@ -1,3 +1,17 @@ +Sun Aug 5 2001 Jim Hague <jim.hague@acm.org> + +* src/client.c: Change variable only used on constant to 'const'. +* src/filter.c: Add a couple of 'return's after ASSERT() to remove + compiler warnings about functions needing returns. +* NEWS,TODO,configure,configure.in,noffle.conf.example,docs/NOTES, + docs/noffle.conf.5,src/client.c,src/configfile.c,src/content.c, + src/control.c,src/database.c,src/fetch.c,src/fetchlist.c,src/filter.c, + src/group.c,src/lock.c,src/log.c,src/log.h,src/noffle.c,src/outgoing.c, + src/post.c,src/protocol.c,src/request.c,src/server.c,src/util.c: + Debug logging is always compiled and selected via noffle.conf. All debug + logs are classified as all, none, config, control, expire, fetch, + filter, newsbase, noffle, post, protocol, requests and server. + Tue May 15 2001 Jim Hague <jim.hague@acm.org> * src/client.c: Only bail out of fetching multiple articles if the
--- a/NEWS Tue Jun 19 11:23:43 2001 +0100 +++ b/NEWS Sun Aug 05 09:24:22 2001 +0100 @@ -8,6 +8,8 @@ * Noffle will act as inews is invoked as inews. * Fetching and reading news can overlap, and generally blocking on the database lock reduced to a minimum. + * Select debug logging via noffle.conf. Logging is always compiled + in, so reduce debug options to build with/without debugging info. 1.0pre7: --------
--- a/TODO Tue Jun 19 11:23:43 2001 +0100 +++ b/TODO Sun Aug 05 09:24:22 2001 +0100 @@ -7,10 +7,6 @@ * Has Client_connect resource leaks if it fails? - * Make debug logging an option in the config file instead of using - a compile time option. This makes it more comfortable for users helping on - bug searches to switch on debug logging temporarily. - Later -----
--- a/configure Tue Jun 19 11:23:43 2001 +0100 +++ b/configure Sun Aug 05 09:24:22 2001 +0100 @@ -14,7 +14,7 @@ ac_help="$ac_help NOFFLE options: - --enable-debug=[no/min/yes] turn on debugging [default=min]" + --enable-debug=[no/yes] build with debugging [default=no]" ac_help="$ac_help --with-docdir=PATH specify where to put the documentation " @@ -2505,28 +2505,19 @@ enableval="$enable_debug" : else - enable_debug=min + enable_debug=no fi if test "x$enable_debug" = "xyes" && test "x$GCC" = "xyes"; then CFLAGS="$CFLAGS \ -Wall -O2 -g -pedantic -ansi -W -Wtraditional -Wshadow -Wpointer-arith \ --Wcast-qual -Wcast-align -Wwrite-strings -Wconversion \ --Waggregate-return -Wstrict-prototypes -Wmissing-prototypes \ --Wmissing-declarations -Wnested-externs -Winline \ --D__USE_BSD -D__USE_XOPEN_EXTENDED -D__USE_POSIX -DDEBUG" -else - - - if test "x$enable_debug" != "xno" && test "x$GCC" = "xyes"; then - CFLAGS="$CFLAGS \ --Wall -O2 -g -pedantic -ansi -W -Wtraditional -Wshadow \ -Wcast-align -Wwrite-strings \ -Wstrict-prototypes -Wmissing-prototypes \ -Wmissing-declarations -Wnested-externs -Winline \ --D__USE_BSD -D__USE_XOPEN_EXTENDED -D__USE_POSIX -DDEBUG" - fi +-D__USE_BSD -D__USE_XOPEN_EXTENDED -D__USE_POSIX" +else + CFLAGS="$CFLAGS -D__USE_BSD -D__USE_XOPEN_EXTENDED -D__USE_POSIX" fi @@ -2537,7 +2528,7 @@ noffle_cv_docdir=$withval else echo $ac_n "checking where to put the documentation""... $ac_c" 1>&6 -echo "configure:2541: checking where to put the documentation" >&5 +echo "configure:2532: checking where to put the documentation" >&5 if eval "test \"`echo '$''{'noffle_cv_docdir'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else
--- a/configure.in Tue Jun 19 11:23:43 2001 +0100 +++ b/configure.in Sun Aug 05 09:24:22 2001 +0100 @@ -124,28 +124,18 @@ AC_ARG_ENABLE(debug, [ NOFFLE options: - --enable-debug=[no/min/yes] turn on debugging [default=min]], , -enable_debug=min) + --enable-debug=[no/yes] build with debugging [default=no]], , +enable_debug=no) if test "x$enable_debug" = "xyes" && test "x$GCC" = "xyes"; then CFLAGS="$CFLAGS \ -Wall -O2 -g -pedantic -ansi -W -Wtraditional -Wshadow -Wpointer-arith \ --Wcast-qual -Wcast-align -Wwrite-strings -Wconversion \ --Waggregate-return -Wstrict-prototypes -Wmissing-prototypes \ --Wmissing-declarations -Wnested-externs -Winline \ --D__USE_BSD -D__USE_XOPEN_EXTENDED -D__USE_POSIX -DDEBUG" -else - - dnl Do nothing if --enable-debug=no - - if test "x$enable_debug" != "xno" && test "x$GCC" = "xyes"; then - CFLAGS="$CFLAGS \ --Wall -O2 -g -pedantic -ansi -W -Wtraditional -Wshadow \ -Wcast-align -Wwrite-strings \ -Wstrict-prototypes -Wmissing-prototypes \ -Wmissing-declarations -Wnested-externs -Winline \ --D__USE_BSD -D__USE_XOPEN_EXTENDED -D__USE_POSIX -DDEBUG" - fi +-D__USE_BSD -D__USE_XOPEN_EXTENDED -D__USE_POSIX" +else + CFLAGS="$CFLAGS -D__USE_BSD -D__USE_XOPEN_EXTENDED -D__USE_POSIX" fi
--- a/docs/NOTES Tue Jun 19 11:23:43 2001 +0100 +++ b/docs/NOTES Sun Aug 05 09:24:22 2001 +0100 @@ -46,18 +46,13 @@ especially with regards to subscribing to groups in "overview" or "thread" mode. -Please send me reports on your experiences. If a reader does not work at all, -compile NOFFLE with - - ./configure --enable-debug - make - make install - -Then you will see every NNTP command and status line in /var/log/news. Most -interesting is the last line, before the reader (or NOFFLE) hangs :-) -Please also send me a short mail, if you successfully used NOFFLE with a -certain version of a news reader for a longer time, so that I can keep this -list up-to-date. +Please send me reports on your experiences. If a reader does not work +at all, add 'log-debug all' to noffle.conf, You will then see every +NNTP command and status line in /var/log/news (or wherever the system +log news debug output ends up). Most interesting is the last line, +before the reader (or NOFFLE) hangs :-) Please also send me a short +mail, if you successfully used NOFFLE with a certain version of a news +reader for a longer time, so that I can keep this list up-to-date. 1.2 kexpress
--- a/docs/noffle.conf.5 Tue Jun 19 11:23:43 2001 +0100 +++ b/docs/noffle.conf.5 Sun Aug 05 09:24:22 2001 +0100 @@ -1,5 +1,5 @@ .TH noffle.conf 5 -.\" $Id: noffle.conf.5 227 2000-10-26 21:21:13Z bears $ +.\" $Id: noffle.conf.5 300 2001-08-05 08:24:22Z bears $ .SH NAME noffle.conf \- Configuration file for NOFFLE news server @@ -89,6 +89,35 @@ Default: The system domain .TP +.B log-debug <log category> [<log category ...] +Log debugging information from the specified log category +or categories. Logging is via the system logging daemon +.BR syslogd (8) +(to the debug facility) and additionally to stderr when running +interactively. The available categories for logging are +.BR all , +.BR none , +.BR config , +.BR control , +.BR expire , +.BR fetch , +.BR filter , +.BR newsbase , +.BR noffle , +.BR post , +.BR protocol , +.BR requests +and +.BR server. +The +.B noffle +category is automatically selected whenever any other category is +selected. These messages are in addition to messages logged to the +system logging daemon error, information and notification facilities. +.br +Default: none + +.TP .B organization <organization> When invoked as .BR inews (1)
--- a/noffle.conf.example Tue Jun 19 11:23:43 2001 +0100 +++ b/noffle.conf.example Sun Aug 05 09:24:22 2001 +0100 @@ -46,6 +46,8 @@ connect-timeout 30 +# Log all protocol traffic +#log-debug protocol # Automatically put groups on fetchlist, if someone accesses them. # Mode can be: full, thread, over
--- a/src/client.c Tue Jun 19 11:23:43 2001 +0100 +++ b/src/client.c Sun Aug 05 09:24:22 2001 +0100 @@ -1,7 +1,7 @@ /* client.c - $Id: client.c 292 2001-05-15 12:07:53Z bears $ + $Id: client.c 300 2001-08-05 08:24:22Z bears $ */ #if HAVE_CONFIG_H @@ -109,7 +109,7 @@ { Prt_putTxtBuf( buf, client.out ); fflush( client.out ); - Log_dbg( "[S FLUSH]" ); + Log_dbg( LOG_DBG_PROTOCOL, "[S FLUSH]" ); } static void @@ -117,7 +117,7 @@ { Prt_putEndOfTxt( client.out ); fflush( client.out ); - Log_dbg( "[S FLUSH]" ); + Log_dbg( LOG_DBG_PROTOCOL, "[S FLUSH]" ); } static Bool @@ -128,7 +128,7 @@ strcpy( client.lastCmd, line ); strcpy( client.lastStat, "[no status available]" ); - Log_dbg( "[S] %s", line ); + Log_dbg( LOG_DBG_PROTOCOL, "[S] %s", line ); n = fprintf( client.out, "%s\r\n", line ); err = ( n != strlen( line ) + 2 ); if ( err ) @@ -148,7 +148,7 @@ if ( ! putCmdLn( line ) ) return FALSE; fflush( client.out ); - Log_dbg( "[S FLUSH]" ); + Log_dbg( LOG_DBG_PROTOCOL, "[S FLUSH]" ); return TRUE; } @@ -486,7 +486,8 @@ groupupdate = TRUE; } else - Log_dbg( "Group %s is already fetched from %s", + Log_dbg( LOG_DBG_FETCH, + "Group %s is already fetched from %s", grp, Grp_server( grp ) ); } } @@ -647,7 +648,7 @@ strcpy( dsc, Utl_restOfLn( line, 1 ) ); if ( Grp_exists( name ) ) { - Log_dbg( "Description of %s: %s", name, dsc ); + Log_dbg( LOG_DBG_FETCH, "Description of %s: %s", name, dsc ); Grp_setDsc( name, dsc ); } } @@ -804,7 +805,9 @@ return NULL; } Utl_cpyStrN( grp, s, pColon - s ); - Log_dbg( "client.c: nextXref: grp '%s' numb %lu", grp, numb ); + Log_dbg( LOG_DBG_FETCH, + "client.c: nextXref: grp '%s' numb %lu", + grp, numb ); return src; } @@ -815,18 +818,18 @@ const char *msgId; int status; time_t lastAccess, nowTime; - double threadFollowTime, secPerDay, maxTime, timeSinceLastAccess; + double threadFollowTime, maxTime, timeSinceLastAccess; ItemList *itl; + const double secPerDay = 24.0 * 3600.0; ASSERT( Lock_gotLock() ); - Log_dbg( "Checking references '%s' for thread mode", ref ); + Log_dbg( LOG_DBG_FETCH, "Checking references '%s' for thread mode", ref ); result = FALSE; itl = new_Itl( ref, " \t" ); nowTime = time( NULL ); threadFollowTime = (double)Cfg_threadFollowTime(); - secPerDay = 24.0 * 3600.0; maxTime = threadFollowTime * secPerDay; - Log_dbg( "Max time = %.0f", maxTime ); + Log_dbg( LOG_DBG_FETCH, "Max time = %.0f", maxTime ); for ( msgId = Itl_first( itl ); msgId != NULL; msgId = Itl_next( itl ) ) { /* @@ -839,7 +842,8 @@ lastAccess = Db_lastAccess( msgId ); interesting = ( status & DB_INTERESTING ); timeSinceLastAccess = difftime( nowTime, lastAccess ); - Log_dbg( "Msg ID '%s': since last access = %.0f, interesting = %s", + Log_dbg( LOG_DBG_FETCH, + "Msg ID '%s': since last access = %.0f, interesting = %s", msgId, timeSinceLastAccess, ( interesting ? "y" : "n" ) ); if ( interesting && timeSinceLastAccess <= maxTime ) { @@ -849,11 +853,12 @@ } else { - Log_dbg( "MsgID '%s': not in database.", msgId ); + Log_dbg( LOG_DBG_FETCH, "MsgID '%s': not in database.", msgId ); } } del_Itl( itl ); - Log_dbg( "Article %s marking for download.", + Log_dbg( LOG_DBG_FETCH, + "Article %s marking for download.", ( result ? "needs" : "doesn't need" ) ); return result; } @@ -868,11 +873,13 @@ ASSERT( Lock_gotLock() ); msgId = Ov_msgId( ov ); if ( Pseudo_isGeneralInfo( msgId ) ) - Log_dbg( "Skipping general info '%s'", msgId ); + Log_dbg( LOG_DBG_FETCH, "Skipping general info '%s'", msgId ); else if ( Db_contains( msgId ) ) { xref = Db_xref( msgId ); - Log_dbg( "Entry '%s' already in db with Xref '%s'", msgId, xref ); + Log_dbg( LOG_DBG_FETCH, + "Entry '%s' already in db with Xref '%s'", + msgId, xref ); p = nextXref( xref, g, &n ); if ( p == NULL ) Log_err( "Overview with no group in Xref '%s'", msgId ); @@ -881,7 +888,8 @@ /* TODO: This code block seems unnessesary. Can we remove it? */ if ( Cfg_servIsPreferential( client.serv, Grp_server( g ) ) ) { - Log_dbg( "Changing first server for '%s' from '%s' to '%s'", + Log_dbg( LOG_DBG_FETCH, + "Changing first server for '%s' from '%s' to '%s'", msgId, Grp_server( g ), client.serv ); snprintf( t, MAXCHAR, "%s:%d %s", client.grp, Ov_numb( ov ), xref ); @@ -889,7 +897,8 @@ } else { - Log_dbg( "Adding '%s' to Xref of '%s'", g, msgId ); + Log_dbg( LOG_DBG_FETCH, + "Adding '%s' to Xref of '%s'", g, msgId ); snprintf( t, MAXCHAR, "%s %s:%d", xref, client.grp, Ov_numb( ov ) ); Db_setXref( msgId, t ); @@ -898,7 +907,7 @@ } else { - Log_dbg( "Preparing '%s' in database", msgId ); + Log_dbg( LOG_DBG_FETCH, "Preparing '%s' in database", msgId ); Db_prepareEntry( ov, client.grp, Ov_numb( ov ) ); } } @@ -929,7 +938,8 @@ return FALSE; } - Log_dbg( "Requesting Newsgroups headers for remote %lu-%lu", + Log_dbg( LOG_DBG_FETCH, + "Requesting Newsgroups headers for remote %lu-%lu", rmtFirst, rmtLast ); newsgroups = collectTxt(); @@ -956,7 +966,9 @@ Log_err( "XOVER command failed: %s", client.lastStat ); return FALSE; } - Log_dbg( "Requesting overview for remote %lu-%lu", rmtFirst, rmtLast ); + Log_dbg( LOG_DBG_FETCH, + "Requesting overview for remote %lu-%lu", + rmtFirst, rmtLast ); response = collectTxt(); if ( response == NULL ) @@ -1147,7 +1159,7 @@ Lock_closeDatabases(); fflush( client.out ); - Log_dbg( "[S FLUSH]" ); + Log_dbg( LOG_DBG_PROTOCOL, "[S FLUSH]" ); p = DynStr_str( s ); res = TRUE;
--- a/src/configfile.c Tue Jun 19 11:23:43 2001 +0100 +++ b/src/configfile.c Sun Aug 05 09:24:22 2001 +0100 @@ -6,7 +6,7 @@ SPOOLDIR VERSION - $Id: configfile.c 227 2000-10-26 21:21:13Z bears $ + $Id: configfile.c 300 2001-08-05 08:24:22Z bears $ */ #if HAVE_CONFIG_H @@ -225,7 +225,9 @@ if ( Wld_match( grp, config.expire[ i ].pattern ) ) { res = config.expire[ i ].days; - Log_dbg( "Custom expire period %d for group %s", res, grp ); + Log_dbg( LOG_DBG_CONFIG, + "Custom expire period %d for group %s", + res, grp ); return res; } @@ -242,7 +244,9 @@ if ( Wld_match( grp, config.autoSubscribeMode[ i ].pattern ) ) { res = config.autoSubscribeMode[ i ].mode; - Log_dbg( "Custom auto subscribe mode %s for group %s", res, grp ); + Log_dbg( LOG_DBG_CONFIG, + "Custom auto subscribe mode %s for group %s", + res, grp ); return res; } @@ -510,6 +514,65 @@ del_Itl( patterns) ; } +static void +getDebugMask( char *line ) +{ + const char *name; + ItemList *maskNames; + const char *maskName; + unsigned mask; + + name = line; + /* Skip over name and terminate it */ + while ( line[ 0 ] != '\0' && ! isspace( line[ 0 ] ) ) + line++; + if ( line[ 0 ] == '\0' ) + { + logSyntaxErr( name ); + return; + } + line[ 0 ] = '\0'; + line++; + + mask = LOG_DBG_NONE; + maskNames = new_Itl( line, " ," ); + for( maskName = Itl_first( maskNames ); + maskName != NULL; + maskName = Itl_next( maskNames ) ) + { + if ( strcmp( maskName, "all" ) == 0 ) + mask = LOG_DBG_ALL; + else if ( strcmp( maskName, "none" ) == 0 ) + mask = LOG_DBG_NONE; + else if ( strcmp( maskName, "config" ) == 0 ) + mask |= LOG_DBG_CONFIG; + else if ( strcmp( maskName, "control" ) == 0 ) + mask |= LOG_DBG_CONTROL; + else if ( strcmp( maskName, "expire" ) == 0 ) + mask |= LOG_DBG_EXPIRE; + else if ( strcmp( maskName, "fetch" ) == 0 ) + mask |= LOG_DBG_FETCH; + else if ( strcmp( maskName, "filter" ) == 0 ) + mask |= LOG_DBG_FILTER; + else if ( strcmp( maskName, "newsbase" ) == 0 ) + mask |= LOG_DBG_NEWSBASE; + else if ( strcmp( maskName, "noffle" ) == 0 ) + mask |= LOG_DBG_NOFFLE; + else if ( strcmp( maskName, "post" ) == 0 ) + mask |= LOG_DBG_POST; + else if ( strcmp( maskName, "protocol" ) == 0 ) + mask |= LOG_DBG_PROTOCOL; + else if ( strcmp( maskName, "requests" ) == 0 ) + mask |= LOG_DBG_REQUESTS; + else if ( strcmp( maskName, "server" ) == 0 ) + mask |= LOG_DBG_SERVER; + else + logSyntaxErr( line ); + } + del_Itl( maskNames) ; + Log_setDbgMask( mask ); +} + static Bool isValidAutoSubscribeMode( const char *mode ) { @@ -745,12 +808,14 @@ if ( strcmp( ruleName, "action" ) != 0 ) { - Log_dbg( "Adding rule type %d value %s", rule.type, value ); + Log_dbg( LOG_DBG_CONFIG, + "Adding rule type %d value %s", + rule.type, value ); Flt_addRule( f, rule ); } } - Log_dbg( "Adding filter, action %d", f->action ); + Log_dbg( LOG_DBG_CONFIG, "Adding filter, action %d", f->action ); Flt_addFilter( f ); return; @@ -820,6 +885,8 @@ getExpire( p ); else if ( strcmp( "auto-subscribe-mode", name ) == 0 ) getAutoSubscribeMode( p ); + else if ( strcmp( "log-debug", name ) == 0 ) + getDebugMask( p ); else if ( strcmp( "getgroups", name ) == 0 ) getGroups( p, TRUE ); else if ( strcmp( "omitgroups", name ) == 0 )
--- a/src/content.c Tue Jun 19 11:23:43 2001 +0100 +++ b/src/content.c Sun Aug 05 09:24:22 2001 +0100 @@ -1,7 +1,7 @@ /* content.c - $Id: content.c 260 2001-02-25 23:29:50Z bears $ + $Id: content.c 300 2001-08-05 08:24:22Z bears $ */ #if HAVE_CONFIG_H @@ -139,11 +139,11 @@ f = fopen( cont.file, "r" ); if ( ! f ) { - Log_dbg( "No group overview file: %s", cont.file ); + Log_dbg( LOG_DBG_NEWSBASE, "No group overview file: %s", cont.file ); setupEmpty( name ); return; } - Log_dbg( "Reading %s", cont.file ); + Log_dbg( LOG_DBG_NEWSBASE, "Reading %s", cont.file ); while ( fgets( line, MAXCHAR, f ) ) { if ( ! ( ov = Ov_read( line ) ) ) @@ -199,7 +199,7 @@ Log_err( "Could not open %s for writing", cont.file ); return; } - Log_dbg( "Writing %s (%lu)", cont.file, cont.size ); + Log_dbg( LOG_DBG_NEWSBASE, "Writing %s (%lu)", cont.file, cont.size ); anythingWritten = FALSE; cont.first = -1; for ( i = 0; i < cont.size; ++i )
--- a/src/control.c Tue Jun 19 11:23:43 2001 +0100 +++ b/src/control.c Sun Aug 05 09:24:22 2001 +0100 @@ -1,7 +1,7 @@ /* control.c - $Id: control.c 60 2000-05-09 22:28:38Z uh1763 $ + $Id: control.c 300 2001-08-05 08:24:22Z bears $ */ #if HAVE_CONFIG_H @@ -65,7 +65,9 @@ if ( ! Grp_local( grp ) && ! seen ) res = CANCEL_NEEDS_MSG; - Log_dbg( "Removed '%s' from group '%s'.", msgId, grp ); + Log_dbg( LOG_DBG_CONTROL, + "Removed '%s' from group '%s'.", + msgId, grp ); } else {
--- a/src/database.c Tue Jun 19 11:23:43 2001 +0100 +++ b/src/database.c Sun Aug 05 09:24:22 2001 +0100 @@ -1,7 +1,7 @@ /* database.c - $Id: database.c 263 2001-02-28 19:01:33Z enz $ + $Id: database.c 300 2001-08-05 08:24:22Z bears $ Uses GNU gdbm library. Using Berkeley db (included in libc6) was cumbersome. It is based on Berkeley db 1.85, which has severe bugs @@ -80,7 +80,7 @@ Log_err( "Error opening %s for r/w (%s)", name, errMsg() ); return FALSE; } - Log_dbg( "%s opened for r/w", name ); + Log_dbg( LOG_DBG_NEWSBASE, "%s opened for r/w", name ); if ( db.txt == NULL ) db.txt = new_DynStr( 5000 ); @@ -95,7 +95,7 @@ Db_close( void ) { ASSERT( db.dbf ); - Log_dbg( "Closing database" ); + Log_dbg( LOG_DBG_NEWSBASE, "Closing database" ); gdbm_close( db.dbf ); db.dbf = NULL; del_DynStr( db.txt ); @@ -128,7 +128,8 @@ dptr = val.dptr; if ( dptr == NULL ) { - Log_dbg( "database.c loadArt: gdbm_fetch found no entry" ); + Log_dbg( LOG_DBG_NEWSBASE, + "database.c loadArt: gdbm_fetch found no entry" ); return FALSE; } @@ -221,7 +222,7 @@ ASSERT( grp ); msgId = Ov_msgId( ov ); - Log_dbg( "Preparing entry %s", msgId ); + Log_dbg( LOG_DBG_NEWSBASE, "Preparing entry %s", msgId ); if ( Db_contains( msgId ) ) Log_err( "Preparing article twice: %s", msgId ); @@ -249,7 +250,7 @@ ASSERT( db.dbf ); - Log_dbg( "Store article %s", msgId ); + Log_dbg( LOG_DBG_NEWSBASE, "Store article %s", msgId ); if ( ! loadArt( msgId ) ) { Log_err( "Cannot find info about '%s' in database", msgId ); @@ -663,7 +664,8 @@ last[ strlen( last ) - 1 ] = '\0'; Utl_cpyStr( now, ctime( &nowTime ) ); last[ strlen( now ) - 1 ] = '\0'; - Log_dbg( "Expiring %s: last access %s, time now %s", + Log_dbg( LOG_DBG_EXPIRE, + "Expiring %s: last access %s, time now %s", msgId, last, now ); #endif ++cntDel; @@ -671,7 +673,8 @@ else if ( ( texpires != (time_t) -1 ) && nowTime > texpires ) { - Log_dbg( "Expiring %s: Expires header activated", msgId ); + Log_dbg( LOG_DBG_EXPIRE, + "Expiring %s: Expires header activated", msgId ); ++cntDel; } else
--- a/src/fetch.c Tue Jun 19 11:23:43 2001 +0100 +++ b/src/fetch.c Sun Aug 05 09:24:22 2001 +0100 @@ -1,7 +1,7 @@ /* fetch.c - $Id: fetch.c 297 2001-06-19 10:23:43Z mnalis $ + $Id: fetch.c 300 2001-08-05 08:24:22Z bears $ */ #if HAVE_CONFIG_H @@ -209,7 +209,7 @@ Bool res; ASSERT( fetch.ready ); - Log_dbg( "Retrieving articles marked for download" ); + Log_dbg( LOG_DBG_FETCH, "Retrieving articles marked for download" ); list = new_DynStr( 10000 ); fetchList = new_DynStr( 1000 ); if ( list == NULL || fetchList == NULL )
--- a/src/fetchlist.c Tue Jun 19 11:23:43 2001 +0100 +++ b/src/fetchlist.c Sun Aug 05 09:24:22 2001 +0100 @@ -1,7 +1,7 @@ /* fetchlist.c - $Id: fetchlist.c 68 2000-05-12 17:28:07Z enz $ + $Id: fetchlist.c 300 2001-08-05 08:24:22Z bears $ */ #if HAVE_CONFIG_H @@ -94,7 +94,7 @@ int ret; Str line, grp, modeStr; - Log_dbg( "Reading %s", file ); + Log_dbg( LOG_DBG_FETCH, "Reading %s", file ); clearList(); if ( ! ( f = fopen( file, "r" ) ) ) {
--- a/src/filter.c Tue Jun 19 11:23:43 2001 +0100 +++ b/src/filter.c Sun Aug 05 09:24:22 2001 +0100 @@ -3,7 +3,7 @@ Article filtering. - $Id: filter.c 189 2000-08-09 21:19:17Z bears $ + $Id: filter.c 300 2001-08-05 08:24:22Z bears $ */ #if HAVE_CONFIG_H @@ -151,6 +151,7 @@ } ASSERT( FALSE ); /* Shouldn't get here */ + return 0; /* Keep compiler quiet */ } /* Check a single filter to see if it fires. */ @@ -202,7 +203,9 @@ for ( i = 0; i < filter.nFilters; i++ ) if ( checkFilter( thisGrp, newsgroups, ov, filter.filters[ i ] ) ) { - Log_dbg( "Filter %d fired on message %s", i, Ov_msgId( ov ) ); + Log_dbg( LOG_DBG_FILTER, + "Filter %d fired on message %s", + i, Ov_msgId( ov ) ); return filter.filters[ i ]->action; } @@ -214,6 +217,7 @@ } ASSERT( FALSE ); /* Shouldn't get here */ + return FILTER_FULL; /* Keep compiler quiet */ } Filter *
--- a/src/group.c Tue Jun 19 11:23:43 2001 +0100 +++ b/src/group.c Sun Aug 05 09:24:22 2001 +0100 @@ -7,7 +7,7 @@ loadGrp() and saveGrp(). This is done transparently. Access to the groups database is done by group name, by the functions defined in group.h. - $Id: group.c 183 2000-07-25 12:14:54Z bears $ + $Id: group.c 300 2001-08-05 08:24:22Z bears $ */ #if HAVE_CONFIG_H @@ -76,7 +76,7 @@ Log_err( "Error opening %s for r/w (%s)", errMsg() ); return FALSE; } - Log_dbg( "%s opened for r/w", name ); + Log_dbg( LOG_DBG_NEWSBASE, "%s opened for r/w", name ); return TRUE; } @@ -84,7 +84,7 @@ Grp_close( void ) { ASSERT( grp.dbf ); - Log_dbg( "Closing groupinfo" ); + Log_dbg( LOG_DBG_NEWSBASE, "Closing groupinfo" ); gdbm_close( grp.dbf ); grp.dbf = NULL; Utl_cpyStr( grp.name, "" );
--- a/src/lock.c Tue Jun 19 11:23:43 2001 +0100 +++ b/src/lock.c Sun Aug 05 09:24:22 2001 +0100 @@ -1,7 +1,7 @@ /* lock.c - $Id: lock.c 292 2001-05-15 12:07:53Z bears $ + $Id: lock.c 300 2001-08-05 08:24:22Z bears $ */ #if HAVE_CONFIG_H @@ -101,7 +101,7 @@ struct flock l; ASSERT( ! gotLock( lock ) ); - Log_dbg( "Waiting for lock %s ...", lock->name ); + Log_dbg( LOG_DBG_NEWSBASE, "Waiting for lock %s ...", lock->name ); if ( lock->lockFile[ 0 ] == '\0' ) snprintf( lock->lockFile, MAXCHAR, "%s/lock/%s", Cfg_spoolDir(), lock->name ); @@ -158,7 +158,7 @@ } lock->lockFd = fd; - Log_dbg( "Lock successful" ); + Log_dbg( LOG_DBG_NEWSBASE, "Lock successful" ); return TRUE; } @@ -177,7 +177,7 @@ strerror( errno ) ); close( lock->lockFd ); lock->lockFd = -1; - Log_dbg( "Releasing lock" ); + Log_dbg( LOG_DBG_NEWSBASE, "Releasing lock" ); } static Bool
--- a/src/log.c Tue Jun 19 11:23:43 2001 +0100 +++ b/src/log.c Sun Aug 05 09:24:22 2001 +0100 @@ -1,7 +1,7 @@ /* log.c - $Id: log.c 79 2000-05-13 15:35:17Z bears $ + $Id: log.c 300 2001-08-05 08:24:22Z bears $ */ #if HAVE_CONFIG_H @@ -16,10 +16,13 @@ #define MAXLENGTH 240 +#define DEFAULT_DBG_MASK LOG_DBG_NONE + struct { Bool interactive; -} log = { FALSE }; + unsigned debugMask; +} log = { FALSE, DEFAULT_DBG_MASK }; void Log_init( const char *name, Bool interactive, int facility ) @@ -73,9 +76,19 @@ } void -Log_dbg( const char *fmt, ... ) +Log_dbg( unsigned subsystem, const char *fmt, ... ) { -#ifdef DEBUG - DO_LOG( LOG_DEBUG ); -#endif + if ( ( subsystem & log.debugMask ) != 0 ) { + DO_LOG( LOG_DEBUG ); + } } + +void +Log_setDbgMask( unsigned mask ) +{ + /* A non-zero mask always include Noffle logs */ + if ( mask != 0 ) + mask |= LOG_DBG_NOFFLE; + + log.debugMask = mask; +}
--- a/src/log.h Tue Jun 19 11:23:43 2001 +0100 +++ b/src/log.h Sun Aug 05 09:24:22 2001 +0100 @@ -3,7 +3,7 @@ Print log messages to syslog, stdout/stderr. - $Id: log.h 79 2000-05-13 15:35:17Z bears $ + $Id: log.h 300 2001-08-05 08:24:22Z bears $ */ #ifndef LOG_H @@ -16,6 +16,26 @@ #include "common.h" /* + Debug logging subsystem identifiers. Can be ORd together. + Debug logging can be turned on in the configuration file; + by default it is off. +*/ +#define LOG_DBG_CONFIG (0x0001) +#define LOG_DBG_CONTROL (0x0002) +#define LOG_DBG_EXPIRE (0x0004) +#define LOG_DBG_FETCH (0x0008) +#define LOG_DBG_FILTER (0x0010) +#define LOG_DBG_NEWSBASE (0x0020) +#define LOG_DBG_NOFFLE (0x0040) +#define LOG_DBG_POST (0x0080) +#define LOG_DBG_PROTOCOL (0x0100) +#define LOG_DBG_REQUESTS (0x0200) +#define LOG_DBG_SERVER (0x0400) + +#define LOG_DBG_ALL (0xffff) +#define LOG_DBG_NONE (0x0000) + +/* Initialise logging (required before using any log functions). name: program name for syslog interactive: print messages also to stderr/stdout @@ -34,14 +54,18 @@ /* Check for cond being true. Otherwise log an error, and return 1. */ int -Log_check(int cond, const char *fmt, ... ); +Log_check( int cond, const char *fmt, ... ); /* Log level notice */ void Log_ntc( const char *fmt, ... ); -/* Log only if DEBUG is defined. */ +/* Log level debug on indicated subsystem */ void -Log_dbg( const char *fmt, ... ); +Log_dbg( unsigned subsystem, const char *fmt, ... ); + +/* Set debug log mask */ +void +Log_setDbgMask( unsigned mask ); #endif
--- a/src/noffle.c Tue Jun 19 11:23:43 2001 +0100 +++ b/src/noffle.c Sun Aug 05 09:24:22 2001 +0100 @@ -10,7 +10,7 @@ received for some seconds (to allow multiple clients connect at the same time). - $Id: noffle.c 279 2001-05-09 11:33:43Z bears $ + $Id: noffle.c 300 2001-08-05 08:24:22Z bears $ */ #if HAVE_CONFIG_H @@ -575,13 +575,13 @@ Log_err( "Cannot set system core limit: %s", strerror( errno ) ); return; } - Log_dbg( "Core limit set to %i", lim.rlim_max ); + Log_dbg( LOG_DBG_NOFFLE, "Core limit set to %i", lim.rlim_max ); if ( chdir( Cfg_spoolDir() ) != 0 ) { Log_err( "Cannot change to directory '%s'", Cfg_spoolDir() ); return; } - Log_dbg( "Changed to directory '%s'", Cfg_spoolDir() ); + Log_dbg( LOG_DBG_NOFFLE, "Changed to directory '%s'", Cfg_spoolDir() ); } static Bool @@ -589,7 +589,7 @@ { Log_init( "noffle", noffle.lockAtStartup, LOG_NEWS ); Cfg_read(); - Log_dbg( "NOFFLE version %s", Cfg_version() ); + Log_dbg( LOG_DBG_NOFFLE, "NOFFLE version %s", Cfg_version() ); if ( noffle.lockAtStartup ) if ( ! Lock_openDatabases() ) return FALSE;
--- a/src/outgoing.c Tue Jun 19 11:23:43 2001 +0100 +++ b/src/outgoing.c Sun Aug 05 09:24:22 2001 +0100 @@ -1,7 +1,7 @@ /* outgoing.c - $Id: outgoing.c 60 2000-05-09 22:28:38Z uh1763 $ + $Id: outgoing.c 300 2001-08-05 08:24:22Z bears $ */ #if HAVE_CONFIG_H @@ -56,7 +56,7 @@ snprintf( dir, MAXCHAR, "%s/outgoing/%s", Cfg_spoolDir(), serv ); r = mkdir( dir, 0755 ); if ( r != 0 ) - Log_dbg( "mkdir: %s", strerror( errno ) ); + Log_dbg( LOG_DBG_NEWSBASE, "mkdir: %s", strerror( errno ) ); } Bool @@ -88,7 +88,7 @@ snprintf( file, MAXCHAR, "%s/outgoing/%s", Cfg_spoolDir(), serv ); if ( ! ( outgoing.dir = opendir( file ) ) ) { - Log_dbg( "Cannot open %s", file ); + Log_dbg( LOG_DBG_NEWSBASE, "Cannot open %s", file ); return FALSE; } Utl_cpyStr( outgoing.serv, serv ); @@ -149,7 +149,7 @@ snprintf( servdir, MAXCHAR, "%s/outgoing", Cfg_spoolDir() ); if ( ! ( d = opendir( servdir ) ) ) { - Log_dbg( "Cannot open %s", servdir ); + Log_dbg( LOG_DBG_NEWSBASE, "Cannot open %s", servdir ); return FALSE; }
--- a/src/post.c Tue Jun 19 11:23:43 2001 +0100 +++ b/src/post.c Sun Aug 05 09:24:22 2001 +0100 @@ -1,7 +1,7 @@ /* post.c - $Id: post.c 278 2001-05-09 11:15:31Z bears $ + $Id: post.c 300 2001-08-05 08:24:22Z bears $ */ #if HAVE_CONFIG_H @@ -76,7 +76,7 @@ Cont_read( grp ); Cont_app( over ); - Log_dbg( "Added message '%s' to group '%s'.", msgId, grp ); + Log_dbg( LOG_DBG_POST, "Added message '%s' to group '%s'.", msgId, grp ); if ( !article.posted ) { @@ -92,7 +92,7 @@ const char *xref; xref = Db_xref( msgId ); - Log_dbg( "Adding '%s' to Xref of '%s'", grp, msgId ); + Log_dbg( LOG_DBG_POST, "Adding '%s' to Xref of '%s'", grp, msgId ); snprintf( t, MAXCHAR, "%s %s:%i", xref, grp, Ov_numb( over ) ); Db_setXref( msgId, t ); } @@ -252,7 +252,7 @@ { if ( article.flags & POST_ADD_FROM ) { - Log_dbg( "Adding From field to posted message." ); + Log_dbg( LOG_DBG_POST, "Adding From field to posted message." ); DynStr_app( s, "From: " ); if ( ! Prt_genFromHdr( article.over.from ) ) { @@ -292,7 +292,9 @@ if ( Cfg_replaceMsgId() ) { Prt_genMsgId( article.over.msgId, article.over.from, "NOFFLE" ); - Log_dbg( "Replacing Message-ID with '%s'", article.over.msgId ); + Log_dbg( LOG_DBG_POST, + "Replacing Message-ID with '%s'", + article.over.msgId ); } else if ( article.over.msgId[ 0 ] == '\0' ) { @@ -307,7 +309,7 @@ { Str path; - Log_dbg( "Adding Path field to posted message." ); + Log_dbg( LOG_DBG_POST, "Adding Path field to posted message." ); DynStr_app( s, "Path: " ); Utl_cpyStr( path, Cfg_pathHeader() ); if ( path[ 0 ] == '\0' ) @@ -318,7 +320,7 @@ /* Ensure Reply-To header */ if ( ! replyToFound ) { - Log_dbg( "Adding Reply-To field to posted message." ); + Log_dbg( LOG_DBG_POST, "Adding Reply-To field to posted message." ); DynStr_app( s, "Reply-To: " ); DynStr_appLn( s, article.over.from ); } @@ -331,7 +333,8 @@ Utl_cpyStr( org, Cfg_organization() ); if ( org[ 0 ] != '\0' ) { - Log_dbg( "Adding Organization field to posted message." ); + Log_dbg( LOG_DBG_POST, + "Adding Organization field to posted message." ); DynStr_app( s, "Organization: " ); DynStr_appLn( s, org ); } @@ -380,7 +383,7 @@ /* OK, try to add it. */ Str sline; - Log_dbg( "Adding .signature to posted message." ); + Log_dbg( LOG_DBG_POST, "Adding .signature to posted message." ); DynStr_appLn( s, BEGIN_SIG ); sigLines++;
--- a/src/protocol.c Tue Jun 19 11:23:43 2001 +0100 +++ b/src/protocol.c Sun Aug 05 09:24:22 2001 +0100 @@ -1,7 +1,7 @@ /* protocol.c - $Id: protocol.c 248 2001-01-25 11:00:03Z bears $ + $Id: protocol.c 300 2001-08-05 08:24:22Z bears $ */ #if HAVE_CONFIG_H @@ -70,7 +70,7 @@ if ( len > 1 && line[ len - 2 ] == '\r' ) line[ len - 2 ] = '\0'; } - Log_dbg( "[R] %s", line ); + Log_dbg( LOG_DBG_PROTOCOL, "[R] %s", line ); return TRUE; } @@ -103,12 +103,12 @@ { if ( line[ 0 ] == '.' ) { - Log_dbg( "[S] .%s", line ); + Log_dbg( LOG_DBG_PROTOCOL, "[S] .%s", line ); return ( fprintf( f, ".%s\r\n", line ) == (int)strlen( line ) + 3 ); } else { - Log_dbg( "[S] %s", line ); + Log_dbg( LOG_DBG_PROTOCOL, "[S] %s", line ); return ( fprintf( f, "%s\r\n", line ) == (int)strlen( line ) + 2 ); } } @@ -116,7 +116,7 @@ Bool Prt_putEndOfTxt( FILE *f ) { - Log_dbg( "[S] ." ); + Log_dbg( LOG_DBG_PROTOCOL, "[S] ." ); return ( fprintf( f, ".\r\n" ) == 3 ); }
--- a/src/request.c Tue Jun 19 11:23:43 2001 +0100 +++ b/src/request.c Sun Aug 05 09:24:22 2001 +0100 @@ -3,7 +3,7 @@ Collection of articles that are marked for download. - $Id: request.c 178 2000-07-22 09:04:20Z enz $ + $Id: request.c 300 2001-08-05 08:24:22Z bears $ */ #if HAVE_CONFIG_H @@ -206,7 +206,7 @@ FILE* file; fileRequest(filename, rs->serv); - Log_dbg("appending to request file %s", filename); + Log_dbg( LOG_DBG_REQUESTS, "appending to request file %s", filename ); if (Log_check((file = fopen(filename, "a")) != 0, "could not open %s for appending: %s", @@ -234,7 +234,7 @@ { Reqserv* rs; ASSERT( is_open ); - Log_dbg( "Marking %s on %s for download", msgId, serv ); + Log_dbg( LOG_DBG_REQUESTS, "Marking %s on %s for download", msgId, serv ); if (getReqserv(serv, &rs) == FALSE) return FALSE; @@ -268,7 +268,7 @@ Reqserv* rs; fileRequest(filename, serv); - Log_dbg("reading request file %s", filename); + Log_dbg( LOG_DBG_REQUESTS, "reading request file %s", filename ); file = fopen(filename, "r"); if (!file && (errno == ENOENT)) { @@ -310,7 +310,7 @@ char** z; fileRequest(filename, rs->serv); - Log_dbg("writing request file %s", filename); + Log_dbg( LOG_DBG_REQUESTS, "writing request file %s", filename ); if (Log_check((file = fopen(filename, "w")) != 0, "could not open %s for writing: %s", @@ -345,7 +345,7 @@ char** z; ASSERT( is_open ); - Log_dbg("Req_remove(\"%s\", \"%s\")", serv, msgId); + Log_dbg( LOG_DBG_REQUESTS, "Req_remove(\"%s\", \"%s\")", serv, msgId ); if (getReqserv(serv, &rs) == FALSE) return; @@ -412,7 +412,7 @@ Bool Req_open(void) { - Log_dbg("opening request database"); + Log_dbg( LOG_DBG_REQUESTS, "opening request database" ); ASSERT(is_open == FALSE); cleanupReqserv(); is_open = TRUE; @@ -426,7 +426,8 @@ { Bool ret = TRUE; Reqserv* rs; - Log_dbg("closing request database, writing changes to disk"); + Log_dbg( LOG_DBG_REQUESTS, + "closing request database, writing changes to disk" ); ASSERT(is_open == TRUE); for (rs = reqserv; rs; rs = rs->next) {
--- a/src/server.c Tue Jun 19 11:23:43 2001 +0100 +++ b/src/server.c Sun Aug 05 09:24:22 2001 +0100 @@ -1,7 +1,7 @@ /* server.c - $Id: server.c 285 2001-05-10 16:00:12Z bears $ + $Id: server.c 300 2001-08-05 08:24:22Z bears $ */ #if HAVE_CONFIG_H @@ -175,7 +175,7 @@ va_end( ap ); snprintf( line, MAXCHAR, "%u %s", stat, s ); DynStr_appLn( server.reply, line ); - Log_dbg( "[S] %s", line ); + Log_dbg( LOG_DBG_PROTOCOL, "[S] %s", line ); } static void @@ -223,7 +223,7 @@ if ( server.eotAfterReply ) Prt_putEndOfTxt( stdout ); fflush( stdout ); - Log_dbg( "[S FLUSH]" ); + Log_dbg( LOG_DBG_PROTOCOL, "[S FLUSH]" ); del_DynStr( server.reply ); }
--- a/src/util.c Tue Jun 19 11:23:43 2001 +0100 +++ b/src/util.c Sun Aug 05 09:24:22 2001 +0100 @@ -1,7 +1,7 @@ /* util.c - $Id: util.c 248 2001-01-25 11:00:03Z bears $ + $Id: util.c 300 2001-08-05 08:24:22Z bears $ */ #if HAVE_CONFIG_H @@ -34,7 +34,6 @@ #if defined(UTIL_TEST) #define Log_err printf -#define Log_dbg printf #endif static const char * @@ -107,7 +106,7 @@ --p; if ( *p != '\n' ) { - Log_dbg( "Utl_ungetLn: not at beginning of line" ); + Log_err( "Utl_ungetLn: not at beginning of line" ); return NULL; } --p;