20
20
#include <string.h>
23
#define LOG_LEVEL_ERR 0
24
#define LOG_LEVEL_INFO 1
25
#define LOG_LEVEL_TRACE 2
23
27
/* Print the message to STDERR (in the sake of portability, we do not use varadic macros) */
24
28
void print_message_to_stderr(const char *fmt,...);
27
31
/* The following defines control what is printed in each logged line */
28
/* Print "stalonetray" */
29
#undef DBG_PRINT_TRAY_PREFIX
30
/* Print the id of the process */
32
/* Print the name of display */
34
/* Print the timestamp */
35
#define DBG_PRINT_TIMESTAMP
36
/* Print the name of a function, file and line which outputs the message */
37
#undef DBG_PRINT_LOCATION
32
/* Print window name */
36
/* Print name of display */
39
#define TRACE_TIMESTAMP
40
/* Print name of a function, file and line which outputs the message */
41
/* Othewise, only function name is printed */
42
#define TRACE_VERBOSE_LOCATION
39
43
/* Print the debug header as specified by defines below */
40
void print_debug_header(const char *funcname, const char *fname, const int line, const int level);
42
/* If trace_mode == True, print all the messages regardless of their debug level */
43
extern int trace_mode;
44
void print_trace_header(const char *funcname, const char *fname, const int line);
45
#define PRINT_TRACE_HEADER() do { \
46
print_trace_header(__FUNC__, __FILE__, __LINE__); \
45
48
/* Print the debug message of specified level */
46
#define DBG(level,message) do { \
47
if (settings.dbg_level >= level || trace_mode) { \
48
print_debug_header(__FUNC__, __FILE__, __LINE__, level); \
49
#define LOG_TRACE(message) do { \
50
if (settings.log_level >= LOG_LEVEL_TRACE) { \
51
PRINT_TRACE_HEADER(); \
49
52
print_message_to_stderr message; \
53
/* Dummy declaration */
54
#define DBG(level,message) do {} while(0)
56
#define PRINT_TRACE_HEADER() do {} while(0)
57
#define LOG_TRACE(message) do {} while(0)
60
#define LOG_ERROR(message) do { \
61
if (settings.log_level >= LOG_LEVEL_TRACE) PRINT_TRACE_HEADER(); \
62
if (settings.log_level >= LOG_LEVEL_ERR) print_message_to_stderr message; \
65
#define LOG_INFO(message) do { \
66
if (settings.log_level >= LOG_LEVEL_TRACE) PRINT_TRACE_HEADER(); \
67
if (settings.log_level >= LOG_LEVEL_INFO) print_message_to_stderr message; \
57
70
/* Print the summary of icon data */
58
71
int print_icon_data(struct TrayIcon *ti);