Revamping Trace Levels and Debugging

Author: Aaron Stone
Date: January 11, 2006
Updated: March 30, 2006

Project Goals

  • Per-subsystem trace levels. [done]
  • Flexible stderr logging. [done, but might need to be redone.]
  • Per-subsystem syslog facilities. [todo great idea!]
  • Per-module trace levels. [todo]
  • Per-user/domain/client syslog facilities [todo but probably very hard]

Config Options

As of DBMail 2.1.SVN from late December 2005, TRACE_LEVEL has been replaced by:

TRACE_SYSLOG=[0-5]
TRACE_STDERR=[0-5]

As of January, 2006, backwards compatibility with TRACE_LEVEL has not been implemented, although it will probably be added soon, with TRACE_LEVEL providing the value for TRACE_SYSLOG unless TRACE_SYSLOG is defined.

The new logging system is intended to aid in debugging, where previously it was sometimes difficult or impossible to get DBMail to log to stderr.

STDERR Logging

I've decided that I don't like the TRACE_STDERR config item. It would make more sense to have stderr logging be controlled exclusively from the command line, with the -v switch. Multiple -v switches would ratchet up the loglevel on stderr. I'll see if I can find time to change this for 2.1.7 – Aaron.

I suggest we should do that but leave the trace_stderr config item in place. It turns out people actually use stderr logging quite a lot. The format for stderr logging has been tweaked to match syslog formatting exactly. – Paul.

Symbolic Trace Levels

Some people would like to be able to set trace levels symbolically, say by setting TRACE_LEVEL = ERRORS or TRACE_LEVEL = DEBUG. This is a good idea, but somewhat hard to implement because it involves a lot of parsing. I'm also not sure that's it's even worth while, because it's pretty easy to document the numeric behavior. Watch, I'll do it in one sentence: Trace levels range from 0 to 5, representing warnings, errors, messages, general information, and debugging information, in that order. Fatal messages are at trace level -1, and probably shouldn't ever be supressed.

New Trace Call

I'm thinking about this signature for a new trace call:

From debug.c:

/* Call me like this:
 *
 * newtrace(TRACE_ERROR, "authldap", __FILE__, __func__,
 *      "Something happened with error code [%d]", resultvar);
 *
 * FIXME: This function doesn't work yet. Think more about how
 * to do this right and then... do it! - Aaron 2006-06-09.
 *
 */

void newtrace(trace_t level, const char * module,
                const char * file, const char * function,
                char *formatstring, ...) PRINTF_ARGS(5, 6);

This ought not be confused with different syslog facilities, though – the scenario here is that you might want all LDAP calls to be traced at the maximum level in order to get your LDAP config working. LDAP calls are made from all of the different DBMail programs, and if each one were in its own syslog facility, you'd want to see that maximum LDAP debugging appear within each of the facilities. I wouldn't want to separate LDAP calls into their own facility because you'd lose the context of where that call was made from.

More ideas

I'd like dbmail to get a logging mode so network administator, who don't need to see the actual dbmail queries (e.g. loglevel 5) but are interested in mailflow. The following would the be logged preferrable on one line:

dbmail-lmtp: envelope sender, receiver, message-ID, message size, storage/queueID, time session start, time session end, session period, if necessary fatal notices, and as bonus the first 32 characters of the subject. fatal notices:= (unknown user/alias mailbox full etc.)

dbmail-pop: userid, session time start, session time end, session time period, fatal notices. fatal notices:= (wrong password [tried wrongpass != goodpass] ), session timeout, client disconnects suddenly etc).

Something that might be handy is logging by domain. something like apache with its vhosts. Such that i can farm off logs for a particular domain to its admin.

It be really neat to have the option of having level 5 logs per user or something.

 
trace_level.txt · Last modified: 2012/02/27 21:44 by bas
 
DBMail is developed by Paul J Stevens together with developers world-wide