Mercurial > hg > nginx-vendor-0-5
comparison src/core/ngx_log.h @ 0:f0b350454894 NGINX_0_1_0
nginx 0.1.0
*) The first public version.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Mon, 04 Oct 2004 00:00:00 +0400 |
parents | |
children | 4b2dafa26fe2 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0b350454894 |
---|---|
1 | |
2 /* | |
3 * Copyright (C) Igor Sysoev | |
4 */ | |
5 | |
6 | |
7 #ifndef _NGX_LOG_H_INCLUDED_ | |
8 #define _NGX_LOG_H_INCLUDED_ | |
9 | |
10 | |
11 #include <ngx_config.h> | |
12 #include <ngx_core.h> | |
13 | |
14 | |
15 #define NGX_LOG_STDERR 0 | |
16 #define NGX_LOG_EMERG 1 | |
17 #define NGX_LOG_ALERT 2 | |
18 #define NGX_LOG_CRIT 3 | |
19 #define NGX_LOG_ERR 4 | |
20 #define NGX_LOG_WARN 5 | |
21 #define NGX_LOG_NOTICE 6 | |
22 #define NGX_LOG_INFO 7 | |
23 #define NGX_LOG_DEBUG 8 | |
24 | |
25 #define NGX_LOG_DEBUG_CORE 0x010 | |
26 #define NGX_LOG_DEBUG_ALLOC 0x020 | |
27 #define NGX_LOG_DEBUG_MUTEX 0x040 | |
28 #define NGX_LOG_DEBUG_EVENT 0x080 | |
29 #define NGX_LOG_DEBUG_HTTP 0x100 | |
30 #define NGX_LOG_DEBUG_IMAP 0x200 | |
31 | |
32 /* | |
33 * do not forget to update debug_levels[] in src/core/ngx_log.c | |
34 * after the adding a new debug level | |
35 */ | |
36 | |
37 #define NGX_LOG_DEBUG_FIRST NGX_LOG_DEBUG_CORE | |
38 #define NGX_LOG_DEBUG_LAST NGX_LOG_DEBUG_IMAP | |
39 #define NGX_LOG_DEBUG_CONNECTION 0x80000000 | |
40 #define NGX_LOG_DEBUG_ALL 0x7ffffff0 | |
41 | |
42 | |
43 typedef size_t (*ngx_log_handler_pt) (void *ctx, char *buf, size_t len); | |
44 | |
45 | |
46 struct ngx_log_s { | |
47 ngx_uint_t log_level; | |
48 ngx_open_file_t *file; | |
49 void *data; | |
50 ngx_log_handler_pt handler; | |
51 }; | |
52 | |
53 #define MAX_ERROR_STR 2048 | |
54 | |
55 | |
56 /*********************************/ | |
57 | |
58 #if (HAVE_GCC_VARIADIC_MACROS) | |
59 | |
60 #define HAVE_VARIADIC_MACROS 1 | |
61 | |
62 #define ngx_log_error(level, log, args...) \ | |
63 if (log->log_level >= level) ngx_log_error_core(level, log, args) | |
64 | |
65 void ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err, | |
66 const char *fmt, ...); | |
67 | |
68 /*********************************/ | |
69 | |
70 #elif (HAVE_C99_VARIADIC_MACROS) | |
71 | |
72 #define HAVE_VARIADIC_MACROS 1 | |
73 | |
74 #define ngx_log_error(level, log, ...) \ | |
75 if (log->log_level >= level) ngx_log_error_core(level, log, __VA_ARGS__) | |
76 | |
77 void ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err, | |
78 const char *fmt, ...); | |
79 | |
80 /*********************************/ | |
81 | |
82 #else /* NO VARIADIC MACROS */ | |
83 | |
84 #define HAVE_VARIADIC_MACROS 0 | |
85 | |
86 void ngx_log_error(ngx_uint_t level, ngx_log_t *log, ngx_err_t err, | |
87 const char *fmt, ...); | |
88 void ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err, | |
89 const char *fmt, va_list args); | |
90 void ngx_log_debug_core(ngx_log_t *log, ngx_err_t err, const char *fmt, ...); | |
91 void ngx_assert_core(ngx_log_t *log, const char *fmt, ...); | |
92 | |
93 | |
94 #endif /* VARIADIC MACROS */ | |
95 | |
96 | |
97 /*********************************/ | |
98 | |
99 #if (NGX_DEBUG) | |
100 | |
101 #if (HAVE_VARIADIC_MACROS) | |
102 | |
103 #define ngx_log_debug0(level, log, err, fmt) \ | |
104 if (log->log_level & level) \ | |
105 ngx_log_error_core(NGX_LOG_DEBUG, log, err, fmt) | |
106 | |
107 #define ngx_log_debug1(level, log, err, fmt, arg1) \ | |
108 if (log->log_level & level) \ | |
109 ngx_log_error_core(NGX_LOG_DEBUG, log, err, fmt, arg1) | |
110 | |
111 #define ngx_log_debug2(level, log, err, fmt, arg1, arg2) \ | |
112 if (log->log_level & level) \ | |
113 ngx_log_error_core(NGX_LOG_DEBUG, log, err, fmt, arg1, arg2) | |
114 | |
115 #define ngx_log_debug3(level, log, err, fmt, arg1, arg2, arg3) \ | |
116 if (log->log_level & level) \ | |
117 ngx_log_error_core(NGX_LOG_DEBUG, log, err, fmt, arg1, arg2, arg3) | |
118 | |
119 #define ngx_log_debug4(level, log, err, fmt, arg1, arg2, arg3, arg4) \ | |
120 if (log->log_level & level) \ | |
121 ngx_log_error_core(NGX_LOG_DEBUG, log, err, fmt, arg1, arg2, arg3, arg4) | |
122 | |
123 #define ngx_log_debug5(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5) \ | |
124 if (log->log_level & level) \ | |
125 ngx_log_error_core(NGX_LOG_DEBUG, log, err, fmt, \ | |
126 arg1, arg2, arg3, arg4, arg5) | |
127 | |
128 #define ngx_log_debug6(level, log, err, fmt, \ | |
129 arg1, arg2, arg3, arg4, arg5, arg6) \ | |
130 if (log->log_level & level) \ | |
131 ngx_log_error_core(NGX_LOG_DEBUG, log, err, fmt, \ | |
132 arg1, arg2, arg3, arg4, arg5, arg6) | |
133 | |
134 #define ngx_log_debug7(level, log, err, fmt, \ | |
135 arg1, arg2, arg3, arg4, arg5, arg6, arg7) \ | |
136 if (log->log_level & level) \ | |
137 ngx_log_error_core(NGX_LOG_DEBUG, log, err, fmt, \ | |
138 arg1, arg2, arg3, arg4, arg5, arg6, arg7) | |
139 | |
140 #else /* NO VARIADIC MACROS */ | |
141 | |
142 #define ngx_log_debug0(level, log, err, fmt) \ | |
143 if (log->log_level & level) \ | |
144 ngx_log_debug_core(log, err, fmt) | |
145 | |
146 #define ngx_log_debug1(level, log, err, fmt, arg1) \ | |
147 if (log->log_level & level) \ | |
148 ngx_log_debug_core(log, err, fmt, arg1) | |
149 | |
150 #define ngx_log_debug2(level, log, err, fmt, arg1, arg2) \ | |
151 if (log->log_level & level) \ | |
152 ngx_log_debug_core(log, err, fmt, arg1, arg2) | |
153 | |
154 #define ngx_log_debug3(level, log, err, fmt, arg1, arg2, arg3) \ | |
155 if (log->log_level & level) \ | |
156 ngx_log_debug_core(log, err, fmt, arg1, arg2, arg3) | |
157 | |
158 #define ngx_log_debug4(level, log, err, fmt, arg1, arg2, arg3, arg4) \ | |
159 if (log->log_level & level) \ | |
160 ngx_log_debug_core(log, err, fmt, arg1, arg2, arg3, arg4) | |
161 | |
162 #define ngx_log_debug5(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5) \ | |
163 if (log->log_level & level) \ | |
164 ngx_log_debug_core(log, err, fmt, arg1, arg2, arg3, arg4, arg5) | |
165 | |
166 #define ngx_log_debug6(level, log, err, fmt, \ | |
167 arg1, arg2, arg3, arg4, arg5, arg6) \ | |
168 if (log->log_level & level) \ | |
169 ngx_log_debug_core(log, err, fmt, arg1, arg2, arg3, arg4, arg5, arg6) | |
170 | |
171 #define ngx_log_debug7(level, log, err, fmt, \ | |
172 arg1, arg2, arg3, arg4, arg5, arg6, arg7) \ | |
173 if (log->log_level & level) \ | |
174 ngx_log_debug_core(log, err, fmt, \ | |
175 arg1, arg2, arg3, arg4, arg5, arg6, arg7) | |
176 | |
177 #endif | |
178 | |
179 #else /* NO NGX_DEBUG */ | |
180 | |
181 #define ngx_log_debug0(level, log, err, fmt) | |
182 #define ngx_log_debug1(level, log, err, fmt, arg1) | |
183 #define ngx_log_debug2(level, log, err, fmt, arg1, arg2) | |
184 #define ngx_log_debug3(level, log, err, fmt, arg1, arg2, arg3) | |
185 #define ngx_log_debug4(level, log, err, fmt, arg1, arg2, arg3, arg4) | |
186 #define ngx_log_debug5(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5) | |
187 #define ngx_log_debug6(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5, arg6) | |
188 #define ngx_log_debug7(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5, \ | |
189 arg6, arg7) | |
190 | |
191 #endif | |
192 | |
193 /*********************************/ | |
194 | |
195 #define ngx_log_alloc_log(pool, log) ngx_palloc(pool, log, sizeof(ngx_log_t)) | |
196 #define ngx_log_copy_log(new, old) ngx_memcpy(new, old, sizeof(ngx_log_t)) | |
197 | |
198 ngx_log_t *ngx_log_init_stderr(); | |
199 #if 0 | |
200 ngx_int_t ngx_log_init_error_log(); | |
201 #endif | |
202 ngx_log_t *ngx_log_create_errlog(ngx_cycle_t *cycle, ngx_array_t *args); | |
203 char *ngx_set_error_log_levels(ngx_conf_t *cf, ngx_log_t *log); | |
204 | |
205 | |
206 | |
207 extern ngx_module_t ngx_errlog_module; | |
208 | |
209 | |
210 #endif /* _NGX_LOG_H_INCLUDED_ */ |