logMsg()
with macrosThere 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.
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.
logMsg()
with macros