Update and clean Tomato RAF files
[tomato.git] / release / src / router / nginx / src / core / ngx_log.h
blob32336478639efa82c08cc56ac1cc3757637f3bd2
2 /*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) Nginx, Inc.
5 */
8 #ifndef _NGX_LOG_H_INCLUDED_
9 #define _NGX_LOG_H_INCLUDED_
12 #include <ngx_config.h>
13 #include <ngx_core.h>
16 #define NGX_LOG_STDERR 0
17 #define NGX_LOG_EMERG 1
18 #define NGX_LOG_ALERT 2
19 #define NGX_LOG_CRIT 3
20 #define NGX_LOG_ERR 4
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
35 * do not forget to update debug_levels[] in src/core/ngx_log.c
36 * after the adding a new debug level
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);
48 struct ngx_log_s {
49 ngx_uint_t log_level;
50 ngx_open_file_t *file;
52 ngx_atomic_uint_t connection;
54 ngx_log_handler_pt handler;
55 void *data;
58 * we declare "action" as "char *" because the actions are usually
59 * the static strings and in the "u_char *" case we have to override
60 * their types all the time
63 char *action;
67 #define NGX_MAX_ERROR_STR 2048
70 /*********************************/
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__)
79 void ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
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__)
86 /*********************************/
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)
95 void ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
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)
102 /*********************************/
104 #else /* NO VARIADIC MACROS */
106 #define NGX_HAVE_VARIADIC_MACROS 0
108 void ngx_cdecl ngx_log_error(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
109 const char *fmt, ...);
110 void ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
111 const char *fmt, va_list args);
112 void ngx_cdecl ngx_log_debug_core(ngx_log_t *log, ngx_err_t err,
113 const char *fmt, ...);
116 #endif /* VARIADIC MACROS */
119 /*********************************/
121 #if (NGX_DEBUG)
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)
159 #else /* NO VARIADIC MACROS */
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)
202 #endif
204 #else /* NO NGX_DEBUG */
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, \
214 arg6, arg7)
215 #define ngx_log_debug8(level, log, err, fmt, arg1, arg2, arg3, arg4, arg5, \
216 arg6, arg7, arg8)
218 #endif
220 /*********************************/
222 ngx_log_t *ngx_log_init(u_char *prefix);
223 ngx_log_t *ngx_log_create(ngx_cycle_t *cycle, ngx_str_t *name);
224 char *ngx_log_set_levels(ngx_conf_t *cf, ngx_log_t *log);
225 void ngx_cdecl ngx_log_abort(ngx_err_t err, const char *fmt, ...);
226 void ngx_cdecl ngx_log_stderr(ngx_err_t err, const char *fmt, ...);
227 u_char *ngx_log_errno(u_char *buf, u_char *last, ngx_err_t err);
231 * ngx_write_stderr() cannot be implemented as macro, since
232 * MSVC does not allow to use #ifdef inside macro parameters.
234 * ngx_write_fd() is used instead of ngx_write_console(), since
235 * CharToOemBuff() inside ngx_write_console() cannot be used with
236 * read only buffer as destination and CharToOemBuff() is not needed
237 * for ngx_write_stderr() anyway.
239 static ngx_inline void
240 ngx_write_stderr(char *text)
242 (void) ngx_write_fd(ngx_stderr, text, strlen(text));
246 extern ngx_module_t ngx_errlog_module;
247 extern ngx_uint_t ngx_use_stderr;
250 #endif /* _NGX_LOG_H_INCLUDED_ */