comparison src/core/ngx_log.h @ 257:70e1c7d2b83d

nginx-0.0.2-2004-02-11-20:08:49 import
author Igor Sysoev <igor@sysoev.ru>
date Wed, 11 Feb 2004 17:08:49 +0000
parents cd71b95716b4
children e91499541410
comparison
equal deleted inserted replaced
256:8e39cab6abd5 257:70e1c7d2b83d
19 #define NGX_LOG_DEBUG_CORE 0x10 19 #define NGX_LOG_DEBUG_CORE 0x10
20 #define NGX_LOG_DEBUG_ALLOC 0x20 20 #define NGX_LOG_DEBUG_ALLOC 0x20
21 #define NGX_LOG_DEBUG_EVENT 0x40 21 #define NGX_LOG_DEBUG_EVENT 0x40
22 #define NGX_LOG_DEBUG_HTTP 0x80 22 #define NGX_LOG_DEBUG_HTTP 0x80
23 23
24 #define NGX_LOG_DEBUG_FIRST NGX_LOG_DEBUG 24 #define NGX_LOG_DEBUG_FIRST NGX_LOG_DEBUG_CORE
25 #define NGX_LOG_DEBUG_LAST NGX_LOG_DEBUG_HTTP 25 #define NGX_LOG_DEBUG_LAST NGX_LOG_DEBUG_HTTP
26 #define NGX_LOG_DEBUG_ALL 0xfffffff8 26 #define NGX_LOG_DEBUG_ALL 0xfffffff0
27 27
28 28
29 /* 29 /*
30 "[%time] [%level] %pid#%tid: %message:(%errno)%errstr, while %action" 30 "[%time] [%level] %pid#%tid: %message:(%errno)%errstr, while %action"
31 " %peer and while processing %context" 31 " %peer and while processing %context"
72 72
73 typedef size_t (*ngx_log_handler_pt) (void *ctx, char *buf, size_t len); 73 typedef size_t (*ngx_log_handler_pt) (void *ctx, char *buf, size_t len);
74 74
75 75
76 struct ngx_log_s { 76 struct ngx_log_s {
77 int log_level; 77 ngx_uint_t log_level;
78 ngx_open_file_t *file; 78 ngx_open_file_t *file;
79 void *data; 79 void *data;
80 ngx_log_handler_pt handler; 80 ngx_log_handler_pt handler;
81 }; 81 };
82 82
83 #define MAX_ERROR_STR 2048 83 #define MAX_ERROR_STR 2048
84 84
85 #define _ ,
86
87 85
88 /*********************************/ 86 /*********************************/
89 87
90 #if (HAVE_GCC_VARIADIC_MACROS) 88 #if (HAVE_GCC_VARIADIC_MACROS)
91 89
92 #define HAVE_VARIADIC_MACROS 1 90 #define HAVE_VARIADIC_MACROS 1
93 91
94 #define ngx_log_error(level, log, args...) \ 92 #define ngx_log_error(level, log, args...) \
95 if (log->log_level >= level) ngx_log_error_core(level, log, args) 93 if (log->log_level >= level) ngx_log_error_core(level, log, args)
96 94
97 #if (NGX_DEBUG)
98 #define ngx_log_debug(log, args...) \
99 if (log->log_level & NGX_LOG_DEBUG) \
100 ngx_log_error_core(NGX_LOG_DEBUG, log, 0, args)
101 #else
102 #define ngx_log_debug(log, args...)
103 #endif
104
105 #define ngx_assert(assert, fallback, log, args...) \
106 if (!(assert)) { \
107 if (log->log_level >= NGX_LOG_ALERT) \
108 ngx_log_error_core(NGX_LOG_ALERT, log, 0, args); \
109 fallback; \
110 }
111
112 void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err, 95 void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err,
113 const char *fmt, ...); 96 const char *fmt, ...);
114 97
115 /*********************************/ 98 /*********************************/
116 99
119 #define HAVE_VARIADIC_MACROS 1 102 #define HAVE_VARIADIC_MACROS 1
120 103
121 #define ngx_log_error(level, log, ...) \ 104 #define ngx_log_error(level, log, ...) \
122 if (log->log_level >= level) ngx_log_error_core(level, log, __VA_ARGS__) 105 if (log->log_level >= level) ngx_log_error_core(level, log, __VA_ARGS__)
123 106
124 #if (NGX_DEBUG)
125 #define ngx_log_debug(log, ...) \
126 if (log->log_level == NGX_LOG_DEBUG) \
127 ngx_log_error_core(NGX_LOG_DEBUG, log, 0, __VA_ARGS__)
128 #else
129 #define ngx_log_debug(log, ...)
130 #endif
131
132 #define ngx_assert(assert, fallback, log, ...) \
133 if (!(assert)) { \
134 if (log->log_level >= NGX_LOG_ALERT) \
135 ngx_log_error_core(NGX_LOG_ALERT, log, 0, __VA_ARGS__); \
136 fallback; \
137 }
138
139 void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err, 107 void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err,
140 const char *fmt, ...); 108 const char *fmt, ...);
141 109
142 /*********************************/ 110 /*********************************/
143 111
144 #else /* NO VARIADIC MACROS */ 112 #else /* NO VARIADIC MACROS */
145 113
146 #define HAVE_VARIADIC_MACROS 0 114 #define HAVE_VARIADIC_MACROS 0
147
148 #if (NGX_DEBUG)
149 #define ngx_log_debug(log, text) \
150 if (log->log_level == NGX_LOG_DEBUG) \
151 ngx_log_debug_core(log, 0, text)
152 #else
153 #define ngx_log_debug(log, text)
154 #endif
155
156 #define ngx_assert(assert, fallback, log, text) \
157 if (!(assert)) { \
158 if (log->log_level >= NGX_LOG_ALERT) \
159 ngx_assert_core(log, text); \
160 fallback; \
161 }
162 115
163 void ngx_log_error(int level, ngx_log_t *log, ngx_err_t err, 116 void ngx_log_error(int level, ngx_log_t *log, ngx_err_t err,
164 const char *fmt, ...); 117 const char *fmt, ...);
165 void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err, 118 void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err,
166 const char *fmt, va_list args); 119 const char *fmt, va_list args);