File: report.h

package info (click to toggle)
lcdproc 0.5.9-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 5,064 kB
  • sloc: ansic: 59,645; sh: 1,740; perl: 681; makefile: 417
file content (100 lines) | stat: -rw-r--r-- 2,954 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/** \file shared/report.h
 * Contains reporting functions.
 *\verbatim
 *
 * To enable the debug() function on all of the software, just type:
 * ./configure --enable-debug
 * and recompile with 'make'
 *
 * To enable the debug() function only in specific files:
 * 1) Configure without enabling debug (that is without --enable-debug)
 * 2) Edit the source file that you want to debug and put the following
 *    line at the top, before the #include "report.h" line:
 *    #define DEBUG
 * 3) Then recompile with 'make'
 *
 * This way, the global DEBUG macro is off but is locally enabled in
 * certains parts of the software.
 *\endverbatim
 */

/*-
 * This file is part of LCDd, the lcdproc server.
 *
 * This file is released under the GNU General Public License. Refer to the
 * COPYING file distributed with this package.
 *
 * Copyright (c) 1999, William Ferrell, Selene Scriven
 *		 2001, Joris Robijn
 *
 */

#ifndef REPORT_H
#define REPORT_H

/* Reporting levels */
/**
 * \def RPT_CRIT
 *	Critical conditions: the program stops right after this.
 *	Only use this if the program is actually exited from the current
 *	function.
 *
 * \def RPT_ERR
 *	Error conditions: serious problem, program continues.
 *	Use this just before you return -1 from a function.
 *
 * \def RPT_WARNING
 *	Warning conditions: Something that the user should Fix, but the
 *	program can continue without a real problem.
 *	Ex: Protocol errors from a client.
 *
 * \def RPT_NOTICE
 *	Major event in the program.
 *	Ex: (un)loading of driver, client (dis)connect.
 *
 * \def RPT_INFO
 *	Minor event in the program: the activation of a Setting, details of a
 *	loaded driver, a key reservation, a keypress, a screen switch.
 *
 * \def RPT_DEBUG
 *	Insignificant event.
 *	Ex: What function has been called, what subpart of a function is being
 *	executed, what was received and sent over the socket, etc.
 */
#define RPT_CRIT 0
#define RPT_ERR 1
#define RPT_WARNING 2
#define RPT_NOTICE 3
#define RPT_INFO 4
#define RPT_DEBUG 5
/* Don't modify these numbers, they're related to syslog! */

/* Reporting destinations */
#define RPT_DEST_STDERR 0
#define RPT_DEST_SYSLOG 1
#define RPT_DEST_STORE 2

/** Sets reporting level and message destination. */
int set_reporting( char *application_name, int new_level, int new_dest );

/** Report the message to the selected destination if important enough */
void report( const int level, const char *format, .../*args*/ );

/**
 * The code that this function generates will not be in the executable when
 * compiled without debugging. This way memory and CPU cycles are saved.
 */
static inline void dont_report( const int level, const char *format, .../*args*/ )
{}

/**
 * Consider the debug function to be exactly the same as the report function.
 * The only difference is that it is only compiled in if DEBUG is defined.
 */
#ifdef DEBUG
#  define debug report
#else
#  define debug dont_report
#endif

#endif  /* REPORT_H */