CAMAC Front-End Documentation : Software Description : Logging Messages : Debug Messages
Previous: Simplifying logMsg() with macros
Next: Function Reference

2.2.2. Debug Messages

There are also a series of macros that can be used for debugging code. These macros take the form dbgMsgn(fmt, arg1, arg2, ..., argn) where n indicates the number of arguments and can be 0 through 5.

Whether the dbgMsg() macros generate code or not depends upon the presense of the NDEBUG macro. If NDEBUG is defined, the macros won't generate any source code. This logic allows the macros to be controlled and used in conjuction with the assert macro.

In addition to being conditionally included, the debug macros also prepend extra information to the format string to aid in debugging the program. Specifically, the file name and line number is reported to the logging facility.

2.2.2.1. Example

When the logging extensions attempt to connect to a remote machine, the socket connection may fail. Since this isn't a fatal error (the remote machine may be down or simply not listening), I reported the error with a debug message:

dbgMsg2("Couldn't connect socket to %s -- %d.",
        machines[ii], errnoGet());

When a nonlistening machine is specified, the logged message looks like this:

0xbe6c08 (tShell): [initlog.cpp#96] Couldn't connect socket to spiv.fnal.gov -- 61.


CAMAC Front-End Documentation : Software Description : Logging Messages : Debug Messages
Previous: Simplifying logMsg() with macros
Next: Function Reference

Security, Privacy, Legal