~ubuntu-branches/ubuntu/saucy/stalonetray/saucy

« back to all changes in this revision

Viewing changes to src/debug.h

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath
  • Date: 2009-10-10 02:05:20 UTC
  • mfrom: (1.1.7 upstream) (3.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091010020520-adj6s9i1ujpvzapo
Tags: 0.8.0~beta1-1
* New upstream release
* bump Standards-Version to 3.8.3
* Remove Torsten from Uploaders as requested

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#include <string.h>
21
21
#include <time.h>
22
22
 
 
23
#define LOG_LEVEL_ERR   0
 
24
#define LOG_LEVEL_INFO  1
 
25
#define LOG_LEVEL_TRACE 2
 
26
 
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,...);
25
29
 
26
30
#ifdef DEBUG
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 */
31
 
#define DBG_PRINT_PID
32
 
/* Print the name of display */
33
 
#define  DBG_PRINT_DPY
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
38
 
 
 
32
/* Print window name */
 
33
#define  TRACE_WM_NAME
 
34
/* Print pid */
 
35
#define TRACE_PID
 
36
/* Print name of display */
 
37
#define TRACE_DPY
 
38
/* Print timestamp */
 
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);
41
 
 
42
 
/* If trace_mode == True, print all the messages regardless of their debug level */
43
 
extern int trace_mode;
44
 
 
 
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__); \
 
47
} while(0)
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; \
50
53
                                                                        }; \
51
54
                                                        } while (0)
52
 
#else /* DEBUG */
53
 
        /* Dummy declaration */
54
 
        #define DBG(level,message)      do {} while(0)
55
 
#endif /* DEBUG */
 
55
#else
 
56
#define PRINT_TRACE_HEADER() do {} while(0)
 
57
#define LOG_TRACE(message) do {} while(0)
 
58
#endif 
 
59
 
 
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; \
 
63
} while(0)
 
64
 
 
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; \
 
68
} while(0)
56
69
 
57
70
/* Print the summary of icon data */
58
71
int print_icon_data(struct TrayIcon *ti);