Debug Messages

Debug messages are designed to be turned on at a specified debug level and are always sent to STDOUT. There are designed to only be used in the development debug process. They are coded as:

DmsgN(level, message, arg1, ...)

where the N is a number indicating how many arguments are to be substituted into the message (i.e. it is a count of the number arguments you have in your message – generally the number of percent signs (%)). level is the debug level at which you wish the message to be printed. message is the debug message to be printed, and arg1, … are the arguments to be substituted. Since not all compilers support #defines with varargs, you must explicitly specify how many arguments you have.

When the debug message is printed, it will automatically be prefixed by the name of the daemon which is running, the filename where the Dmsg is, and the line number within the file.

Some actual examples are:

Dmsg2(20, "MD5len=\%d MD5=\%s\n", strlen(buf), buf);
Dmsg1(9, "Created client \%s record\n", client->hdr.name);

Debug Tags

It is possible to use tags to organize debug messages. When using a tag, it is possible to hide/show an entire class of messages. The message tags are defined in lib/messages.c/h

...
#define    DT_SCHEDULER  (1<<23)                /* scheduler */
#define    DT_PROTOCOL   (1<<22)                /* protocol */
#define    DT_DEDUP      (1<<21)                /* BEEF deduplication */
#define    DT_DDE        (1<<20)                /* BEEF dedup engine */
#define    DT_SNAPSHOT   (1<<19)                /* Snapshot */
#define    DT_RECORD     (1<<18)                /* Record/block */
#define    DT_CLOUD      (1<<17)                /* cloud   */
#define    DT_ALL        (0x7FFF0000)           /* all (up to debug_level 65635, 15 flags available) */

/* setdebug tag=all,-plugin */
static struct debugtags debug_tags[] = {
...
 { NT_("scheduler"),   DT_SCHEDULER,_("Debug scheduler information")},
 { NT_("protocol"),    DT_PROTOCOL, _("Debug protocol information")},
 { NT_("snapshot"),    DT_SNAPSHOT, _("Debug snapshots")},
 { NT_("record"),      DT_RECORD,   _("Debug records")},
 { NT_("all"),         DT_ALL,      _("Debug all information")},
 { NULL,               0,   NULL}
};

In the code, the tag can be used like in the following example:

Dmsg0(DT_CLOUD|50, "This is a message about cloud\n");

The message will be displayed if the cloud tag is set AND if the debug level is at least 50.

setdebug level=50 tags=cloud storage

Possible Next Steps

Go back to Message Classes.

Go back to Developer Notes.

Go back to Developer Guide.