8 #ifndef _NGX_LOG_H_INCLUDED_
9 #define _NGX_LOG_H_INCLUDED_
16 #define NGX_LOG_STDERR 0
17 #define NGX_LOG_EMERG 1
18 #define NGX_LOG_ALERT 2
19 #define NGX_LOG_CRIT 3
21 #define NGX_LOG_WARN 5
22 #define NGX_LOG_NOTICE 6
23 #define NGX_LOG_INFO 7
24 #define NGX_LOG_DEBUG 8
26 #define NGX_LOG_DEBUG_CORE 0x010
27 #define NGX_LOG_DEBUG_ALLOC 0x020
28 #define NGX_LOG_DEBUG_MUTEX 0x040
29 #define NGX_LOG_DEBUG_EVENT 0x080
30 #define NGX_LOG_DEBUG_HTTP 0x100
31 #define NGX_LOG_DEBUG_MAIL 0x200
32 #define NGX_LOG_DEBUG_MYSQL 0x400
39 #define NGX_LOG_DEBUG_FIRST NGX_LOG_DEBUG_CORE
40 #define NGX_LOG_DEBUG_LAST NGX_LOG_DEBUG_MYSQL
41 #define NGX_LOG_DEBUG_CONNECTION 0x80000000
42 #define NGX_LOG_DEBUG_ALL 0x7ffffff0
45 typedef u_char *(*ngx_log_handler_pt) (
ngx_log_t *log, u_char *buf,
size_t len);
67 #define NGX_MAX_ERROR_STR 2048
72 #if (NGX_HAVE_C99_VARIADIC_MACROS)
74 #define NGX_HAVE_VARIADIC_MACROS 1
76 #define ngx_log_error(level, log, ...) \
77 if ((log)->log_level >= level) ngx_log_error_core(level, log, __VA_ARGS__)
80 const char *fmt, ...);
82 #define ngx_log_debug(level, log, ...) \
83 if ((log)->log_level & level) \
84 ngx_log_error_core(NGX_LOG_DEBUG, log, __VA_ARGS__)
88 #elif (NGX_HAVE_GCC_VARIADIC_MACROS)
90 #define NGX_HAVE_VARIADIC_MACROS 1
92 #define ngx_log_error(level, log, args...) \
93 if ((log)->log_level >= level) ngx_log_error_core(level, log, args)
96 const char *fmt, ...);
98 #define ngx_log_debug(level, log, args...) \
99 if ((log)->log_level & level) \
100 ngx_log_error_core(NGX_LOG_DEBUG, log, args)
106 #define NGX_HAVE_VARIADIC_MACROS 0
109 const char *fmt, ...);
111 const char *fmt, va_list args);
113 const char *fmt, ...);
123 #if (NGX_HAVE_VARIADIC_MACROS)
125 #define ngx_log_debug0(level, log, err, fmt) \
126 ngx_log_debug(level, log, err, fmt)
128 #define ngx_log_debug1(level, log, err, fmt, arg1) \
129 ngx_log_debug(level, log, err, fmt, arg1)
131 #define ngx_log_debug2(level, log, err, fmt, arg1, arg2) \
132 ngx_log_debug(level, log, err, fmt, arg1, arg2)
134 #define ngx_log_debug3(level, log, err, fmt, arg1, arg2, arg3) \
135 ngx_log_debug(level, log, err, fmt, arg1, arg2, arg3)
137 #define ngx_log_debug4(level, log, err, fmt, arg1, arg2, arg3, arg4) \
138 ngx_log_debug(level, log, err, fmt, arg1, arg2, arg3, arg4)
140 #define ngx_log_debug5(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5) \
141 ngx_log_debug(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5)
143 #define ngx_log_debug6(level, log, err, fmt, \
144 arg1, arg2, arg3, arg4, arg5, arg6) \
145 ngx_log_debug(level, log, err, fmt, \
146 arg1, arg2, arg3, arg4, arg5, arg6)
148 #define ngx_log_debug7(level, log, err, fmt, \
149 arg1, arg2, arg3, arg4, arg5, arg6, arg7) \
150 ngx_log_debug(level, log, err, fmt, \
151 arg1, arg2, arg3, arg4, arg5, arg6, arg7)
153 #define ngx_log_debug8(level, log, err, fmt, \
154 arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) \
155 ngx_log_debug(level, log, err, fmt, \
156 arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
161 #define ngx_log_debug0(level, log, err, fmt) \
162 if ((log)->log_level & level) \
163 ngx_log_debug_core(log, err, fmt)
165 #define ngx_log_debug1(level, log, err, fmt, arg1) \
166 if ((log)->log_level & level) \
167 ngx_log_debug_core(log, err, fmt, arg1)
169 #define ngx_log_debug2(level, log, err, fmt, arg1, arg2) \
170 if ((log)->log_level & level) \
171 ngx_log_debug_core(log, err, fmt, arg1, arg2)
173 #define ngx_log_debug3(level, log, err, fmt, arg1, arg2, arg3) \
174 if ((log)->log_level & level) \
175 ngx_log_debug_core(log, err, fmt, arg1, arg2, arg3)
177 #define ngx_log_debug4(level, log, err, fmt, arg1, arg2, arg3, arg4) \
178 if ((log)->log_level & level) \
179 ngx_log_debug_core(log, err, fmt, arg1, arg2, arg3, arg4)
181 #define ngx_log_debug5(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5) \
182 if ((log)->log_level & level) \
183 ngx_log_debug_core(log, err, fmt, arg1, arg2, arg3, arg4, arg5)
185 #define ngx_log_debug6(level, log, err, fmt, \
186 arg1, arg2, arg3, arg4, arg5, arg6) \
187 if ((log)->log_level & level) \
188 ngx_log_debug_core(log, err, fmt, arg1, arg2, arg3, arg4, arg5, arg6)
190 #define ngx_log_debug7(level, log, err, fmt, \
191 arg1, arg2, arg3, arg4, arg5, arg6, arg7) \
192 if ((log)->log_level & level) \
193 ngx_log_debug_core(log, err, fmt, \
194 arg1, arg2, arg3, arg4, arg5, arg6, arg7)
196 #define ngx_log_debug8(level, log, err, fmt, \
197 arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) \
198 if ((log)->log_level & level) \
199 ngx_log_debug_core(log, err, fmt, \
200 arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
206 #define ngx_log_debug0(level, log, err, fmt)
207 #define ngx_log_debug1(level, log, err, fmt, arg1)
208 #define ngx_log_debug2(level, log, err, fmt, arg1, arg2)
209 #define ngx_log_debug3(level, log, err, fmt, arg1, arg2, arg3)
210 #define ngx_log_debug4(level, log, err, fmt, arg1, arg2, arg3, arg4)
211 #define ngx_log_debug5(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5)
212 #define ngx_log_debug6(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5, arg6)
213 #define ngx_log_debug7(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5, \
215 #define ngx_log_debug8(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5, \
240 ngx_write_stderr(
char *text)
242 (void) ngx_write_fd(
ngx_stderr, text, strlen(text));