Mercurial > hg > nginx-quic
comparison src/core/ngx_log.h @ 0:4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
The first code that uses "ngx_" prefix, the previous one used "gx_" prefix.
At that point the code is not yet usable. The first draft ideas are dated
back to 23.10.2001.
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 06 Aug 2002 16:39:45 +0000 |
parents | |
children | 34a521b1a148 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4eff17414a43 |
---|---|
1 #ifndef _NGX_LOG_H_INCLUDED_ | |
2 #define _NGX_LOG_H_INCLUDED_ | |
3 | |
4 | |
5 #include <ngx_errno.h> | |
6 | |
7 typedef enum { | |
8 NGX_LOG_EMERG = 0, | |
9 NGX_LOG_ALERT, | |
10 NGX_LOG_CRIT, | |
11 NGX_LOG_ERR, | |
12 NGX_LOG_WARN, | |
13 NGX_LOG_NOTICE, | |
14 NGX_LOG_INFO, | |
15 NGX_LOG_DEBUG | |
16 } ngx_log_e; | |
17 | |
18 /* | |
19 "... while ", action = "reading client request headers" | |
20 "... while reading client request headers" | |
21 "... while ", action = "reading client request headers" | |
22 context: pop3 user account | |
23 "... while reading client command for 'john_doe'" | |
24 */ | |
25 | |
26 typedef struct { | |
27 int log_level; | |
28 char *action; | |
29 char *context; | |
30 /* char *func(ngx_log_t *log); */ | |
31 } ngx_log_t; | |
32 | |
33 #define MAX_ERROR_STR 2048 | |
34 | |
35 #define _ , | |
36 | |
37 | |
38 #if (HAVE_GCC_VARIADIC_MACROS) | |
39 | |
40 #define HAVE_VARIADIC_MACROS 1 | |
41 | |
42 #define ngx_log_error(level, log, args...) \ | |
43 if (log->log_level >= level) ngx_log_error_core(level, log, args) | |
44 | |
45 #ifdef NGX_DEBUG | |
46 #define ngx_log_debug(log, args...) \ | |
47 if (log->log_level == NGX_LOG_DEBUG) \ | |
48 ngx_log_error_core(NGX_LOG_DEBUG, log, 0, args) | |
49 #else | |
50 #define ngx_log_debug(log, args...) | |
51 #endif | |
52 | |
53 #define ngx_assert(assert, fallback, log, args...) \ | |
54 if (!(assert)) { \ | |
55 if (log->log_level >= NGX_LOG_ALERT) \ | |
56 ngx_log_error_core(NGX_LOG_ALERT, log, 0, args); \ | |
57 fallback; \ | |
58 } | |
59 | |
60 void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err, | |
61 const char *fmt, ...); | |
62 | |
63 #elif (HAVE_C99_VARIADIC_MACROS) | |
64 | |
65 #define HAVE_VARIADIC_MACROS 1 | |
66 | |
67 #define ngx_log_error(level, log, ...) \ | |
68 if (log->log_level >= level) ngx_log_error_core(level, log, __VA_ARGS__) | |
69 | |
70 #ifdef NGX_DEBUG | |
71 #define ngx_log_debug(log, ...) \ | |
72 if (log->log_level == NGX_LOG_DEBUG) \ | |
73 ngx_log_error_core(NGX_LOG_DEBUG, log, 0, __VA_ARGS__) | |
74 #else | |
75 #define ngx_log_debug(log, ...) | |
76 #endif | |
77 | |
78 #define ngx_assert(assert, fallback, log, ...) \ | |
79 if (!(assert)) { \ | |
80 if (log->log_level >= NGX_LOG_ALERT) \ | |
81 ngx_log_error_core(NGX_LOG_ALERT, log, 0, __VA_ARGS__); \ | |
82 fallback; \ | |
83 } | |
84 | |
85 void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err, | |
86 const char *fmt, ...); | |
87 | |
88 #else /* NO VARIADIC MACROS */ | |
89 | |
90 #include <stdarg.h> | |
91 | |
92 #ifdef NGX_DEBUG | |
93 #define ngx_log_debug(log, text) \ | |
94 if (log->log_level == NGX_LOG_DEBUG) \ | |
95 ngx_log_debug_core(log, text) | |
96 #else | |
97 #define ngx_log_debug(log, text) | |
98 #endif | |
99 | |
100 #define ngx_assert(assert, fallback, log, text) \ | |
101 if (!(assert)) { \ | |
102 if (log->log_level >= NGX_LOG_ALERT) \ | |
103 ngx_assert_core(log, text); \ | |
104 fallback; \ | |
105 } | |
106 | |
107 void ngx_log_error(int level, ngx_log_t *log, ngx_err_t err, | |
108 const char *fmt, ...); | |
109 void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err, | |
110 const char *fmt, va_list args); | |
111 void ngx_log_debug_core(ngx_log_t *log, const char *fmt, ...); | |
112 void ngx_assert_core(ngx_log_t *log, const char *fmt, ...); | |
113 | |
114 | |
115 #endif /* VARIADIC MACROS */ | |
116 | |
117 | |
118 #endif /* _NGX_LOG_H_INCLUDED_ */ |