Mercurial > hg > nginx
comparison src/core/ngx_log.h @ 201:267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Sun, 30 Nov 2003 20:03:18 +0000 |
parents | 71ce40b3c37b |
children | 0b67be7d4489 |
comparison
equal
deleted
inserted
replaced
200:abeaebe0a33c | 201:267ea1d98683 |
---|---|
4 | 4 |
5 #include <ngx_config.h> | 5 #include <ngx_config.h> |
6 #include <ngx_core.h> | 6 #include <ngx_core.h> |
7 | 7 |
8 | 8 |
9 typedef enum { | 9 #define NGX_LOG_STDERR 0 |
10 NGX_LOG_STDERR = 0, | 10 #define NGX_LOG_EMERG 1 |
11 NGX_LOG_EMERG, | 11 #define NGX_LOG_ALERT 2 |
12 NGX_LOG_ALERT, | 12 #define NGX_LOG_CRIT 3 |
13 NGX_LOG_CRIT, | 13 #define NGX_LOG_ERR 4 |
14 NGX_LOG_ERR, | 14 #define NGX_LOG_WARN 5 |
15 NGX_LOG_WARN, | 15 #define NGX_LOG_NOTICE 6 |
16 NGX_LOG_NOTICE, | 16 #define NGX_LOG_INFO 7 |
17 NGX_LOG_INFO, | 17 #define NGX_LOG_DEBUG 8 |
18 NGX_LOG_DEBUG | 18 |
19 } ngx_log_e; | 19 #define NGX_LOG_DEBUG_HTTP 0x80 |
20 | 20 |
21 | 21 |
22 /* | 22 /* |
23 "[%time] [%level] %pid#%tid: %message:(%errno)%errstr, while %action" | 23 "[%time] [%level] %pid#%tid: %message:(%errno)%errstr, while %action" |
24 " %peer and while processing %context" | 24 " %peer and while processing %context" |
69 struct ngx_log_s { | 69 struct ngx_log_s { |
70 int log_level; | 70 int log_level; |
71 ngx_open_file_t *file; | 71 ngx_open_file_t *file; |
72 void *data; | 72 void *data; |
73 ngx_log_handler_pt handler; | 73 ngx_log_handler_pt handler; |
74 | |
75 #if 0 | |
76 /* STUB */ | |
77 char *action; | |
78 char *context; | |
79 /* */ | |
80 #endif | |
81 }; | 74 }; |
82 | 75 |
83 #define MAX_ERROR_STR 2048 | 76 #define MAX_ERROR_STR 2048 |
84 | 77 |
85 #define _ , | 78 #define _ , |
86 | 79 |
80 | |
81 /*********************************/ | |
87 | 82 |
88 #if (HAVE_GCC_VARIADIC_MACROS) | 83 #if (HAVE_GCC_VARIADIC_MACROS) |
89 | 84 |
90 #define HAVE_VARIADIC_MACROS 1 | 85 #define HAVE_VARIADIC_MACROS 1 |
91 | 86 |
92 #define ngx_log_error(level, log, args...) \ | 87 #define ngx_log_error(level, log, args...) \ |
93 if (log->log_level >= level) ngx_log_error_core(level, log, args) | 88 if (log->log_level >= level) ngx_log_error_core(level, log, args) |
94 | 89 |
95 #if (NGX_DEBUG) | 90 #if (NGX_DEBUG) |
96 #define ngx_log_debug(log, args...) \ | 91 #define ngx_log_debug(log, args...) \ |
97 if (log->log_level == NGX_LOG_DEBUG) \ | 92 if (log->log_level & NGX_LOG_DEBUG) \ |
98 ngx_log_error_core(NGX_LOG_DEBUG, log, 0, args) | 93 ngx_log_error_core(NGX_LOG_DEBUG, log, 0, args) |
99 #else | 94 #else |
100 #define ngx_log_debug(log, args...) | 95 #define ngx_log_debug(log, args...) |
101 #endif | 96 #endif |
102 | 97 |
108 } | 103 } |
109 | 104 |
110 void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err, | 105 void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err, |
111 const char *fmt, ...); | 106 const char *fmt, ...); |
112 | 107 |
108 /*********************************/ | |
113 | 109 |
114 #elif (HAVE_C99_VARIADIC_MACROS) | 110 #elif (HAVE_C99_VARIADIC_MACROS) |
115 | 111 |
116 #define HAVE_VARIADIC_MACROS 1 | 112 #define HAVE_VARIADIC_MACROS 1 |
117 | 113 |
134 } | 130 } |
135 | 131 |
136 void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err, | 132 void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err, |
137 const char *fmt, ...); | 133 const char *fmt, ...); |
138 | 134 |
135 /*********************************/ | |
139 | 136 |
140 #else /* NO VARIADIC MACROS */ | 137 #else /* NO VARIADIC MACROS */ |
138 | |
139 #define HAVE_VARIADIC_MACROS 0 | |
141 | 140 |
142 #if (NGX_DEBUG) | 141 #if (NGX_DEBUG) |
143 #define ngx_log_debug(log, text) \ | 142 #define ngx_log_debug(log, text) \ |
144 if (log->log_level == NGX_LOG_DEBUG) \ | 143 if (log->log_level == NGX_LOG_DEBUG) \ |
145 ngx_log_debug_core(log, text) | 144 ngx_log_debug_core(log, 0, text) |
146 #else | 145 #else |
147 #define ngx_log_debug(log, text) | 146 #define ngx_log_debug(log, text) |
148 #endif | 147 #endif |
149 | 148 |
150 #define ngx_assert(assert, fallback, log, text) \ | 149 #define ngx_assert(assert, fallback, log, text) \ |
156 | 155 |
157 void ngx_log_error(int level, ngx_log_t *log, ngx_err_t err, | 156 void ngx_log_error(int level, ngx_log_t *log, ngx_err_t err, |
158 const char *fmt, ...); | 157 const char *fmt, ...); |
159 void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err, | 158 void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err, |
160 const char *fmt, va_list args); | 159 const char *fmt, va_list args); |
161 void ngx_log_debug_core(ngx_log_t *log, const char *fmt, ...); | 160 void ngx_log_debug_core(ngx_log_t *log, ngx_err_t err, const char *fmt, ...); |
162 void ngx_assert_core(ngx_log_t *log, const char *fmt, ...); | 161 void ngx_assert_core(ngx_log_t *log, const char *fmt, ...); |
163 | 162 |
164 | 163 |
165 #endif /* VARIADIC MACROS */ | 164 #endif /* VARIADIC MACROS */ |
166 | 165 |
166 | |
167 /*********************************/ | |
168 | |
169 #if (HAVE_VARIADIC_MACROS) | |
170 | |
171 #if (NGX_DEBUG) | |
172 #define ngx_log_debug0(level, log, err, fmt) \ | |
173 if (log->log_level & level) \ | |
174 ngx_log_error_core(NGX_LOG_DEBUG, log, err, fmt) | |
175 #else | |
176 #define ngx_log_debug0(level, log, err, fmt) | |
177 #endif | |
178 | |
179 #if (NGX_DEBUG) | |
180 #define ngx_log_debug1(level, log, err, fmt, arg1) \ | |
181 if (log->log_level & level) \ | |
182 ngx_log_error_core(NGX_LOG_DEBUG, log, err, fmt, arg1) | |
183 #else | |
184 #define ngx_log_debug1(level, log, err, fmt, arg1) | |
185 #endif | |
186 | |
187 /*********************************/ | |
188 | |
189 #else /* NO VARIADIC MACROS */ | |
190 | |
191 #if (NGX_DEBUG) | |
192 #define ngx_log_debug0(level, log, err, fmt) \ | |
193 if (log->log_level & level) \ | |
194 ngx_log_debug_core(log, err, fmt) | |
195 #else | |
196 #define ngx_log_debug0(level, log, err, fmt) | |
197 #endif | |
198 | |
199 #if (NGX_DEBUG) | |
200 #define ngx_log_debug1(level, log, err, fmt, arg1) \ | |
201 if (log->log_level & level) \ | |
202 ngx_log_debug_core(log, err, fmt, arg1) | |
203 #else | |
204 #define ngx_log_debug1(level, log, err, fmt, arg1) | |
205 #endif | |
206 #endif | |
207 | |
208 | |
209 /*********************************/ | |
167 | 210 |
168 #define ngx_log_alloc_log(pool, log) ngx_palloc(pool, log, sizeof(ngx_log_t)) | 211 #define ngx_log_alloc_log(pool, log) ngx_palloc(pool, log, sizeof(ngx_log_t)) |
169 #define ngx_log_copy_log(new, old) ngx_memcpy(new, old, sizeof(ngx_log_t)) | 212 #define ngx_log_copy_log(new, old) ngx_memcpy(new, old, sizeof(ngx_log_t)) |
170 | 213 |
171 ngx_log_t *ngx_log_init_errlog(); | 214 ngx_log_t *ngx_log_init_errlog(); |