3 * This file is part of LCDd, the lcdproc server.
5 * This file is released under the GNU General Public License. Refer to the
6 * COPYING file distributed with this package.
8 * Copyright (c) 1999, William Ferrell, Scott Scriven
16 /* DEBUGGING / REPORTING
18 * To enable the debug() function on all of the software, just type:
19 * ./configure --enable-debug
20 * and recompile with 'make'
22 * To enable the debug() function only in specific files:
23 * 1) Configure without enabling debug (that is without --enable-debug)
24 * 2) Edit the source file that you want to debug and put the following
25 * line at the top, before the #include "report.h" line:
27 * 3) Then recompile with 'make'
28 * This way, the global DEBUG macro is off but is locally enabled in
29 * certains parts of the software.
31 * The reporting levels have the following meaning:
33 * 0 RPT_CRIT Critical conditions: the program stops right after
34 * this. Only use this if the program is actually exited
35 * from the current function.
36 * 1 RPT_ERR Error conditions: serious problem, program continues.
37 * Use this just before you return -1 from a function.
38 * 2 RPT_WARNING Warning conditions: Something that the user should
39 * fix, but the program can continue without a real
41 * Ex: Protocol errors from a client.
42 * 3 RPT_NOTICE Major event in the program.
43 * Ex: (un)loading of driver, client (dis)connect.
44 * 4 RPT_INFO Minor event in the program: the activation of a
45 * setting, details of a loaded driver, a key
46 * reservation, a keypress, a screen switch.
47 * 5 RPT_DEBUG Insignificant event.
48 * Ex: What function has been called, what subpart of a
49 * function is being executed, what was received and sent
50 * over the socket, etc.
52 * Levels 4 (maybe) and 5 (certainly) should be reported using the debug
54 * The code that this function generates will not be in the executable when
55 * compiled without debugging. This way memory and CPU cycles are saved.
66 /* Reporting levels */
73 /* Don't just modify these numbers, they're related to syslog. */
75 /* Reporting destinations */
76 #define RPT_DEST_STDERR 0
77 #define RPT_DEST_SYSLOG 1
78 #define RPT_DEST_STORE 2
80 int set_reporting( char *application_name
, int new_level
, int new_dest
);
81 /* Sets reporting level and message destination. */
83 void report( const int level
, const char *format
, .../*args*/ );
84 /* Report the message to the selected destination if important enough */
86 /* Consider the debug function to be exactly the same as the report function.
87 * The only difference is that it is only compiled in if DEBUG is defined.
90 static inline void dont_report( const int level
, const char *format
, .../*args*/ )
91 {} /* The idea is that this gets optimized out */
96 # define debug dont_report