-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog.h
executable file
·95 lines (80 loc) · 2.07 KB
/
log.h
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
/** @file log.h
Entrelacs log internal log sytem.
*/
#ifndef __LOG_H__
#define __LOG_H__
#define LOG_OFF 0
#define LOG_FATAL 1
#define LOG_ERROR 2
#define LOG_WARN 3
#define LOG_INFO 4
#define LOG_TRACE 5
#define LOG_DEBUG 6
enum _log_facility
{
LOG_GENERAL=0,
LOG_MEM0,
LOG_MEM,
LOG_SPACE,
LOG_MACHINE,
LOG_SESSION,
LOG_SERVER,
LOG_FACILITY_COUNT
};
#ifndef LOG_CURRENT
#define LOG_CURRENT LOG_GENERAL
#endif
#ifdef __LOG_C__
char *facility_name[] = {
"general",
"mem0",
"mem",
"space",
"machine",
"session",
"server",
0
};
char *level_name[] = {
"off",
"fatal",
"error",
"warn",
"info",
"trace",
"debug",
0
};
#endif
extern int log_level[LOG_FACILITY_COUNT];
extern int log_init(const char *filename, const char *debug_str);
extern void log_msg(int level, enum _log_facility facility, char *fname, int lineno, char *fmt, ...);
extern int log_verbose();
#define LOGPRINTF(level, fmt, arg...) { log_msg(level, LOG_CURRENT, __FILE__, __LINE__, fmt, ##arg); }
#ifdef DEBUG
#define ONDEBUG(w) w
#else
#define ONDEBUG(w)
#endif
#ifdef PRODUCTION
#define FATALPRINTF(format, arg...) (void)(0)
#define ERRORPRINTF(format, arg...) (void)(0)
#define WARNPRINTF(format, arg...) (void)(0)
#define INFOPRINTF(format, arg...) (void)(0)
#define TRACEPRINTF(format, arg...) (void)(0)
#define DEBUGPRINTF(format, arg...) (void)(0)
#else
#define FATALPRINTF(format, arg...) LOGPRINTF(LOG_FATAL, format, ##arg)
#define ERRORPRINTF(format, arg...) LOGPRINTF(LOG_ERROR, format, ##arg)
#define WARNPRINTF(format, arg...) LOGPRINTF(LOG_WARN, format, ##arg)
#define INFOPRINTF(format, arg...) LOGPRINTF(LOG_INFO, format, ##arg)
#ifdef DEBUG
#define TRACEPRINTF(format, arg...) LOGPRINTF(LOG_TRACE, format, ##arg)
#define DEBUGPRINTF(format, arg...) LOGPRINTF(LOG_DEBUG, format, ##arg)
#else
#define TRACEPRINTF(format, arg...) LOGPRINTF(LOG_TRACE, format, ##arg)
#define DEBUGPRINTF(format, arg...) (void)(0)
#endif
#endif
#define dputs(format, arg...) DEBUGPRINTF(format, ##arg)
#endif /* __LOG_H__ */