kviewshell
debug.h File Reference
#include <stdio.h>
Go to the source code of this file.
Defines | |
debug.h | |
Files #"debug.h"# and #"debug.cpp"# implement means to print debug messages in a multithread safe way. Message are also marked with a thread identifier. Under Windows, debug messages are directly sent to the debugger using the Win32 function OutputDebugString#. Under Unix, debug messages are printed on the controlling terminal, preferably using device #/dev/tty#. The preprocessor variable DEBUGLVL# defines which debug code is going to be compiled. Selecting #-DDEBUGLVL=0# (the default) disables all debugging code. Selecting a positive values (e.g. #-DDEBUGLVL=4#) enables more and more debugging code. Message output is controlled by the current debugging level (an integer between #0# and DEBUGLVL#). Greater values enable more messages. The initial debugging level is set to the maximum value. The debugging level can be changed using macro {DEBUG_SET_LEVEL}.
Message indentation can be modified using macro {DEBUG_MAKE_INDENT}. Messages are generated by macro {DEBUG_MSG} or its variants. The argument of the macro can contain several components separated by operator #<<#, as demonstrated in the example below: {verbatim} DEBUG_MSG("The value of a[" << n << "] is " << a[n] << ' One more preprocessor variable RUNTIME_DEBUG_ONLY# enables compilation of debug code, but does not enable the debug messages automatically. In order to see them the program should use {DEBUG_SET_LEVEL} to change the level to anything greater than 0. Normally this happens when user specifies option #-debug# in the command line. Usage of RUNTIME_DEBUG_ONLY# implies DEBUGLVL=1# if not specified otherwise. Finally, #-DNO_DEBUG# or #-DNDEBUG# can be used instead of #-DDEBUGLVL=0#, and #-D_DEBUG# can be used instead of #-DDEBUGLVL=0#. { Historical Comment} --- Debug macros are rarely used in the reference DjVu library because Leon thinks that debugging messages unnecessarily clutter the code. Debug macros are used everywhere in the plugin code because Andrew thinks that code without debugging messages is close to useless. No agreement could be reached. Neither could they agree on if cluttering header files with huge documentation chunks helps to improve code readability. Macros for printing debug messages.
| |
#define | DEBUG1_MSG(x) |
#define | DEBUG1_MSGF(x) |
#define | DEBUG2_MSG(x) |
#define | DEBUG2_MSGF(x) |
#define | DEBUG3_MSG(x) |
#define | DEBUG3_MSGF(x) |
#define | DEBUG4_MSG(x) |
#define | DEBUG4_MSGF(x) |
#define | DEBUG_MAKE_INDENT(x) |
#define | DEBUG_MSG(x) DEBUG1_MSG(x) |
#define | DEBUG_MSG_LVL(level, x) |
#define | DEBUG_MSGF(x) DEBUG1_MSGF(x) |
#define | DEBUG_MSGN(x) DEBUG_MSG(x<<'\n') |
#define | DEBUG_MSGN_LVL(level, x) |
#define | DEBUG_RUNTIME_SET_LEVEL(level) DEBUG_SET_LEVEL(level) |
#define | DEBUG_SET_LEVEL(level) |
#define | DEBUGLVL 0 |
Define Documentation
#define DEBUG_MSG | ( | x | ) | DEBUG1_MSG(x) |
#define DEBUG_MSGF | ( | x | ) | DEBUG1_MSGF(x) |
#define DEBUG_MSGN | ( | x | ) | DEBUG_MSG(x<<'\n') |
#define DEBUG_RUNTIME_SET_LEVEL | ( | level | ) | DEBUG_SET_LEVEL(level) |