Macros For Logging and Debugging

The Seiscomp3 library provides some easy to use macros for generating debugging and logging output.

The option logging.level = n in the config files or the command line options --verbosity n or -v[vvv] controls which of the macros will generate output at runtime. n is a number between 0 and 4.

The macros work in a similar way as the printf() function in standard C. They accept a format string of type char* (or just text) and optional variables of different types that are inserted in the format string where there are % signs.

Example:

#include <seiscomp3/logging/log.h>

...

int number = 5;
SEISCOMP_DEBUG("The number is %d", number);

...

If logging.level is set to 0 none of the macros below will produce any output.

SEISCOMP_ERROR()

Will produce output when logging.level is equal to or greater than 1.

This is used to output error messages for grave errors that might cause the program to fail.

SEISCOMP_WARNING()

Will produce output when logging.level is equal to or greater than 2.

This is used to output warning messages for problems that the operator should be aware of, but are not causing a complete failure.

SEISCOMP_INFO()

Will produce output when logging.level is equal to or greater than 3.

This is used to output information that might be interesting for the user, but is not indicating a problem.

SEISCOMP_DEBUG()

Will produce output when logging.level is equal to or greater than 4.

This is used to output debugging info that usually is only needed for testing and not for normal use.