Mercurial > hg > nginx
annotate src/core/ngx_log.c @ 3496:fb88801564de
build nginx/Windows against OpenSSL-0.9.8n, since nginx-0.8.35
built against OpenSSL-1.0.0 crashed on Windows XP somewhere
in the NTDLL.DLL on the master process exit
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 21 Apr 2010 15:09:17 +0000 |
parents | d478379e51ac |
children | dd1570b6f237 |
rev | line source |
---|---|
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
440
diff
changeset
|
1 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
440
diff
changeset
|
2 /* |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
443
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
440
diff
changeset
|
4 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
440
diff
changeset
|
5 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
6 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 #include <ngx_config.h> |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
83
diff
changeset
|
8 #include <ngx_core.h> |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
11 static char *ngx_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); |
100
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
12 |
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
13 |
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
14 static ngx_command_t ngx_errlog_commands[] = { |
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
15 |
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
16 {ngx_string("error_log"), |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
17 NGX_MAIN_CONF|NGX_CONF_1MORE, |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
18 ngx_error_log, |
100
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
19 0, |
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
20 0, |
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
21 NULL}, |
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
22 |
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
23 ngx_null_command |
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
24 }; |
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
25 |
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
26 |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
27 static ngx_core_module_t ngx_errlog_module_ctx = { |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
28 ngx_string("errlog"), |
577 | 29 NULL, |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
30 NULL |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
31 }; |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
32 |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
33 |
100
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
34 ngx_module_t ngx_errlog_module = { |
509 | 35 NGX_MODULE_V1, |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
36 &ngx_errlog_module_ctx, /* module context */ |
100
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
37 ngx_errlog_commands, /* module directives */ |
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
38 NGX_CORE_MODULE, /* module type */ |
541 | 39 NULL, /* init master */ |
116
571bcbff82c5
nginx-0.0.1-2003-07-11-08:50:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
115
diff
changeset
|
40 NULL, /* init module */ |
541 | 41 NULL, /* init process */ |
42 NULL, /* init thread */ | |
43 NULL, /* exit thread */ | |
44 NULL, /* exit process */ | |
45 NULL, /* exit master */ | |
46 NGX_MODULE_V1_PADDING | |
100
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
47 }; |
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
48 |
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
49 |
415
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
379
diff
changeset
|
50 static ngx_log_t ngx_log; |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
51 static ngx_open_file_t ngx_log_file; |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
52 ngx_uint_t ngx_use_stderr = 1; |
100
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
53 |
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
54 |
2741
cda3738a85bd
use ngx_str_t for error levels
Igor Sysoev <igor@sysoev.ru>
parents:
2737
diff
changeset
|
55 static ngx_str_t err_levels[] = { |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
56 ngx_null_string, |
2741
cda3738a85bd
use ngx_str_t for error levels
Igor Sysoev <igor@sysoev.ru>
parents:
2737
diff
changeset
|
57 ngx_string("emerg"), |
cda3738a85bd
use ngx_str_t for error levels
Igor Sysoev <igor@sysoev.ru>
parents:
2737
diff
changeset
|
58 ngx_string("alert"), |
cda3738a85bd
use ngx_str_t for error levels
Igor Sysoev <igor@sysoev.ru>
parents:
2737
diff
changeset
|
59 ngx_string("crit"), |
cda3738a85bd
use ngx_str_t for error levels
Igor Sysoev <igor@sysoev.ru>
parents:
2737
diff
changeset
|
60 ngx_string("error"), |
cda3738a85bd
use ngx_str_t for error levels
Igor Sysoev <igor@sysoev.ru>
parents:
2737
diff
changeset
|
61 ngx_string("warn"), |
2742
e138f820b5dc
style fix: remove trailing spaces introduced in the previous commit
Igor Sysoev <igor@sysoev.ru>
parents:
2741
diff
changeset
|
62 ngx_string("notice"), |
e138f820b5dc
style fix: remove trailing spaces introduced in the previous commit
Igor Sysoev <igor@sysoev.ru>
parents:
2741
diff
changeset
|
63 ngx_string("info"), |
2741
cda3738a85bd
use ngx_str_t for error levels
Igor Sysoev <igor@sysoev.ru>
parents:
2737
diff
changeset
|
64 ngx_string("debug") |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
65 }; |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
66 |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
67 static const char *debug_levels[] = { |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
68 "debug_core", "debug_alloc", "debug_mutex", "debug_event", |
1136 | 69 "debug_http", "debug_mail", "debug_mysql" |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
70 }; |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
71 |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
72 |
455 | 73 #if (NGX_HAVE_VARIADIC_MACROS) |
503 | 74 |
75 void | |
76 ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err, | |
77 const char *fmt, ...) | |
78 | |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
79 #else |
503 | 80 |
81 void | |
82 ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err, | |
83 const char *fmt, va_list args) | |
84 | |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
85 #endif |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
86 { |
455 | 87 #if (NGX_HAVE_VARIADIC_MACROS) |
461 | 88 va_list args; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
89 #endif |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
90 u_char *p, *last, *msg; |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
91 u_char errstr[NGX_MAX_ERROR_STR]; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
92 |
119
cd54bcbaf3b5
nginx-0.0.1-2003-07-21-01:15:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
116
diff
changeset
|
93 if (log->file->fd == NGX_INVALID_FILE) { |
cd54bcbaf3b5
nginx-0.0.1-2003-07-21-01:15:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
116
diff
changeset
|
94 return; |
cd54bcbaf3b5
nginx-0.0.1-2003-07-21-01:15:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
116
diff
changeset
|
95 } |
cd54bcbaf3b5
nginx-0.0.1-2003-07-21-01:15:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
116
diff
changeset
|
96 |
461 | 97 last = errstr + NGX_MAX_ERROR_STR; |
98 | |
182
3c49eaf3f522
nginx-0.0.1-2003-11-13-09:14:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
123
diff
changeset
|
99 ngx_memcpy(errstr, ngx_cached_err_log_time.data, |
3c49eaf3f522
nginx-0.0.1-2003-11-13-09:14:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
123
diff
changeset
|
100 ngx_cached_err_log_time.len); |
3c49eaf3f522
nginx-0.0.1-2003-11-13-09:14:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
123
diff
changeset
|
101 |
461 | 102 p = errstr + ngx_cached_err_log_time.len; |
236
86e473b5641e
nginx-0.0.1-2004-01-22-09:47:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
235
diff
changeset
|
103 |
2764
d4a717592877
use ngx_vslprintf(), ngx_slprintf()
Igor Sysoev <igor@sysoev.ru>
parents:
2758
diff
changeset
|
104 p = ngx_slprintf(p, last, " [%V] ", &err_levels[level]); |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
105 |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
28
diff
changeset
|
106 /* pid#tid */ |
2764
d4a717592877
use ngx_vslprintf(), ngx_slprintf()
Igor Sysoev <igor@sysoev.ru>
parents:
2758
diff
changeset
|
107 p = ngx_slprintf(p, last, "%P#" NGX_TID_T_FMT ": ", |
933
1ce231663322
ngx_sprintf() has implicit limit of 65536 bytes so on Linux/ppc64
Igor Sysoev <igor@sysoev.ru>
parents:
860
diff
changeset
|
108 ngx_log_pid, ngx_log_tid); |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
109 |
483 | 110 if (log->connection) { |
2764
d4a717592877
use ngx_vslprintf(), ngx_slprintf()
Igor Sysoev <igor@sysoev.ru>
parents:
2758
diff
changeset
|
111 p = ngx_slprintf(p, last, "*%uA ", log->connection); |
483 | 112 } |
113 | |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
114 msg = p; |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
115 |
455 | 116 #if (NGX_HAVE_VARIADIC_MACROS) |
191
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
186
diff
changeset
|
117 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
118 va_start(args, fmt); |
2764
d4a717592877
use ngx_vslprintf(), ngx_slprintf()
Igor Sysoev <igor@sysoev.ru>
parents:
2758
diff
changeset
|
119 p = ngx_vslprintf(p, last, fmt, args); |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
120 va_end(args); |
191
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
186
diff
changeset
|
121 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
122 #else |
191
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
186
diff
changeset
|
123 |
2764
d4a717592877
use ngx_vslprintf(), ngx_slprintf()
Igor Sysoev <igor@sysoev.ru>
parents:
2758
diff
changeset
|
124 p = ngx_vslprintf(p, last, fmt, args); |
191
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
186
diff
changeset
|
125 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
126 #endif |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
127 |
6
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
128 if (err) { |
2765 | 129 p = ngx_log_errno(p, last, err); |
6
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
130 } |
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
131 |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
28
diff
changeset
|
132 if (level != NGX_LOG_DEBUG && log->handler) { |
483 | 133 p = log->handler(log, p, last - p); |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
28
diff
changeset
|
134 } |
6
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
135 |
571 | 136 if (p > last - NGX_LINEFEED_SIZE) { |
137 p = last - NGX_LINEFEED_SIZE; | |
461 | 138 } |
139 | |
571 | 140 ngx_linefeed(p); |
467 | 141 |
2302
2abf14c952a2
compatibility with glibc 2.3, warn_unused_result attribute for write()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
142 (void) ngx_write_fd(log->file->fd, errstr, p - errstr); |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
143 |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
144 if (!ngx_use_stderr |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
145 || level > NGX_LOG_WARN |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
146 || log->file->fd == ngx_stderr) |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
147 { |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
148 return; |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
149 } |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
150 |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
151 msg -= (err_levels[level].len + 4); |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
152 |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
153 (void) ngx_sprintf(msg, "[%V]: ", &err_levels[level]); |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
154 |
2769
9d986c4e796f
introduce ngx_write_console() to support OEM code pages
Igor Sysoev <igor@sysoev.ru>
parents:
2765
diff
changeset
|
155 (void) ngx_write_console(ngx_stderr, msg, p - msg); |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
156 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
157 |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
83
diff
changeset
|
158 |
455 | 159 #if !(NGX_HAVE_VARIADIC_MACROS) |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
160 |
503 | 161 void ngx_cdecl |
162 ngx_log_error(ngx_uint_t level, ngx_log_t *log, ngx_err_t err, | |
163 const char *fmt, ...) | |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
164 { |
461 | 165 va_list args; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
166 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
167 if (log->log_level >= level) { |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
168 va_start(args, fmt); |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
169 ngx_log_error_core(level, log, err, fmt, args); |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
170 va_end(args); |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
171 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
172 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
173 |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
83
diff
changeset
|
174 |
503 | 175 void ngx_cdecl |
176 ngx_log_debug_core(ngx_log_t *log, ngx_err_t err, const char *fmt, ...) | |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
177 { |
461 | 178 va_list args; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
179 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
180 va_start(args, fmt); |
201
267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
181 ngx_log_error_core(NGX_LOG_DEBUG, log, err, fmt, args); |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
182 va_end(args); |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
183 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
184 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
185 #endif |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
83
diff
changeset
|
186 |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
83
diff
changeset
|
187 |
2752
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
188 void ngx_cdecl |
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
189 ngx_log_abort(ngx_err_t err, const char *fmt, ...) |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
639
diff
changeset
|
190 { |
2752
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
191 u_char *p; |
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
192 va_list args; |
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
193 u_char errstr[NGX_MAX_CONF_ERRSTR]; |
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
194 |
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
195 va_start(args, fmt); |
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
196 p = ngx_vsnprintf(errstr, sizeof(errstr) - 1, fmt, args); |
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
197 va_end(args); |
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
198 |
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
199 ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, err, |
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
200 "%*s", p - errstr, errstr); |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
639
diff
changeset
|
201 } |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
639
diff
changeset
|
202 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
639
diff
changeset
|
203 |
2722 | 204 void ngx_cdecl |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
205 ngx_log_stderr(ngx_err_t err, const char *fmt, ...) |
2722 | 206 { |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
207 u_char *p, *last; |
2722 | 208 va_list args; |
209 u_char errstr[NGX_MAX_ERROR_STR]; | |
210 | |
2764
d4a717592877
use ngx_vslprintf(), ngx_slprintf()
Igor Sysoev <igor@sysoev.ru>
parents:
2758
diff
changeset
|
211 last = errstr + NGX_MAX_ERROR_STR; |
d4a717592877
use ngx_vslprintf(), ngx_slprintf()
Igor Sysoev <igor@sysoev.ru>
parents:
2758
diff
changeset
|
212 |
2722 | 213 va_start(args, fmt); |
2764
d4a717592877
use ngx_vslprintf(), ngx_slprintf()
Igor Sysoev <igor@sysoev.ru>
parents:
2758
diff
changeset
|
214 p = ngx_vslprintf(errstr, last, fmt, args); |
2722 | 215 va_end(args); |
216 | |
2765 | 217 if (err) { |
218 p = ngx_log_errno(p, last, err); | |
2722 | 219 } |
220 | |
2765 | 221 if (p > last - NGX_LINEFEED_SIZE) { |
222 p = last - NGX_LINEFEED_SIZE; | |
2732 | 223 } |
224 | |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
225 ngx_linefeed(p); |
2732 | 226 |
2769
9d986c4e796f
introduce ngx_write_console() to support OEM code pages
Igor Sysoev <igor@sysoev.ru>
parents:
2765
diff
changeset
|
227 (void) ngx_write_console(ngx_stderr, errstr, p - errstr); |
2722 | 228 } |
229 | |
230 | |
2765 | 231 u_char * |
232 ngx_log_errno(u_char *buf, u_char *last, ngx_err_t err) | |
233 { | |
234 if (buf > last - 50) { | |
235 | |
236 /* leave a space for an error code */ | |
237 | |
238 buf = last - 50; | |
239 *buf++ = '.'; | |
240 *buf++ = '.'; | |
241 *buf++ = '.'; | |
242 } | |
243 | |
244 #if (NGX_WIN32) | |
245 buf = ngx_slprintf(buf, last, ((unsigned) err < 0x80000000) | |
246 ? " (%d: " : " (%Xd: ", err); | |
247 #else | |
248 buf = ngx_slprintf(buf, last, " (%d: ", err); | |
249 #endif | |
250 | |
251 buf = ngx_strerror_r(err, buf, last - buf); | |
252 | |
253 if (buf < last) { | |
254 *buf++ = ')'; | |
255 } | |
256 | |
257 return buf; | |
258 } | |
259 | |
260 | |
503 | 261 ngx_log_t * |
2758 | 262 ngx_log_init(u_char *prefix) |
100
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
263 { |
2758 | 264 u_char *p, *name; |
265 size_t nlen, plen; | |
266 | |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
267 ngx_log.file = &ngx_log_file; |
461 | 268 ngx_log.log_level = NGX_LOG_NOTICE; |
105
00bee6e7b485
nginx-0.0.1-2003-06-15-22:32:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
103
diff
changeset
|
269 |
2758 | 270 name = (u_char *) NGX_ERROR_LOG_PATH; |
271 | |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
272 /* |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
273 * we use ngx_strlen() here since BCC warns about |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
274 * condition is always false and unreachable code |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
275 */ |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
276 |
2758 | 277 nlen = ngx_strlen(name); |
278 | |
279 if (nlen == 0) { | |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
280 ngx_log_file.fd = ngx_stderr; |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
281 return &ngx_log; |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
282 } |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
283 |
2758 | 284 p = NULL; |
285 | |
286 #if (NGX_WIN32) | |
287 if (name[1] != ':') { | |
288 #else | |
289 if (name[0] != '/') { | |
290 #endif | |
291 | |
292 if (prefix) { | |
293 plen = ngx_strlen(prefix); | |
294 | |
2773
7a44b1932741
fix building by BCC if NGX_PREFIX is defined
Igor Sysoev <igor@sysoev.ru>
parents:
2769
diff
changeset
|
295 } else { |
2758 | 296 #ifdef NGX_PREFIX |
297 prefix = (u_char *) NGX_PREFIX; | |
298 plen = ngx_strlen(prefix); | |
2773
7a44b1932741
fix building by BCC if NGX_PREFIX is defined
Igor Sysoev <igor@sysoev.ru>
parents:
2769
diff
changeset
|
299 #else |
7a44b1932741
fix building by BCC if NGX_PREFIX is defined
Igor Sysoev <igor@sysoev.ru>
parents:
2769
diff
changeset
|
300 plen = 0; |
2758 | 301 #endif |
302 } | |
303 | |
304 if (plen) { | |
305 name = malloc(plen + nlen + 2); | |
306 if (name == NULL) { | |
307 return NULL; | |
308 } | |
309 | |
310 p = ngx_cpymem(name, prefix, plen); | |
311 | |
312 if (!ngx_path_separator(*(p - 1))) { | |
313 *p++ = '/'; | |
314 } | |
315 | |
316 ngx_cpystrn(p, (u_char *) NGX_ERROR_LOG_PATH, nlen + 1); | |
317 | |
318 p = name; | |
319 } | |
320 } | |
321 | |
322 ngx_log_file.fd = ngx_open_file(name, NGX_FILE_APPEND, | |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
323 NGX_FILE_CREATE_OR_OPEN, |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
324 NGX_FILE_DEFAULT_ACCESS); |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
325 |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
326 if (ngx_log_file.fd == NGX_INVALID_FILE) { |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
327 ngx_log_stderr(ngx_errno, |
2758 | 328 "[alert]: could not open error log file: " |
329 ngx_open_file_n " \"%s\" failed", name); | |
461 | 330 #if (NGX_WIN32) |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
331 ngx_event_log(ngx_errno, |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
332 "could not open error log file: " |
2758 | 333 ngx_open_file_n " \"%s\" failed", name); |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
334 #endif |
100
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
335 |
2758 | 336 ngx_log_file.fd = ngx_stderr; |
337 } | |
338 | |
339 if (p) { | |
340 ngx_free(p); | |
461 | 341 } |
207
6e0fef527732
nginx-0.0.1-2003-12-05-20:07:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
342 |
448
241dc8092a33
nginx-0.1.0-2004-10-01-19:53:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
445
diff
changeset
|
343 return &ngx_log; |
241dc8092a33
nginx-0.1.0-2004-10-01-19:53:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
445
diff
changeset
|
344 } |
241dc8092a33
nginx-0.1.0-2004-10-01-19:53:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
445
diff
changeset
|
345 |
241dc8092a33
nginx-0.1.0-2004-10-01-19:53:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
445
diff
changeset
|
346 |
503 | 347 ngx_log_t * |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
348 ngx_log_create(ngx_cycle_t *cycle, ngx_str_t *name) |
109
a9bc21d63fe4
nginx-0.0.1-2003-07-02-18:41:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
106
diff
changeset
|
349 { |
a9bc21d63fe4
nginx-0.0.1-2003-07-02-18:41:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
106
diff
changeset
|
350 ngx_log_t *log; |
a9bc21d63fe4
nginx-0.0.1-2003-07-02-18:41:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
106
diff
changeset
|
351 |
501 | 352 log = ngx_pcalloc(cycle->pool, sizeof(ngx_log_t)); |
353 if (log == NULL) { | |
415
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
379
diff
changeset
|
354 return NULL; |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
379
diff
changeset
|
355 } |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
379
diff
changeset
|
356 |
501 | 357 log->file = ngx_conf_open_file(cycle, name); |
358 if (log->file == NULL) { | |
415
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
379
diff
changeset
|
359 return NULL; |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
379
diff
changeset
|
360 } |
119
cd54bcbaf3b5
nginx-0.0.1-2003-07-21-01:15:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
116
diff
changeset
|
361 |
109
a9bc21d63fe4
nginx-0.0.1-2003-07-02-18:41:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
106
diff
changeset
|
362 return log; |
a9bc21d63fe4
nginx-0.0.1-2003-07-02-18:41:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
106
diff
changeset
|
363 } |
a9bc21d63fe4
nginx-0.0.1-2003-07-02-18:41:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
106
diff
changeset
|
364 |
a9bc21d63fe4
nginx-0.0.1-2003-07-02-18:41:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
106
diff
changeset
|
365 |
503 | 366 char * |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
367 ngx_log_set_levels(ngx_conf_t *cf, ngx_log_t *log) |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
232
diff
changeset
|
368 { |
290
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
278
diff
changeset
|
369 ngx_uint_t i, n, d; |
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
278
diff
changeset
|
370 ngx_str_t *value; |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
232
diff
changeset
|
371 |
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
232
diff
changeset
|
372 value = cf->args->elts; |
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
232
diff
changeset
|
373 |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
374 for (i = 2; i < cf->args->nelts; i++) { |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
375 |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
249
diff
changeset
|
376 for (n = 1; n <= NGX_LOG_DEBUG; n++) { |
2741
cda3738a85bd
use ngx_str_t for error levels
Igor Sysoev <igor@sysoev.ru>
parents:
2737
diff
changeset
|
377 if (ngx_strcmp(value[i].data, err_levels[n].data) == 0) { |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
378 |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
232
diff
changeset
|
379 if (log->log_level != 0) { |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
380 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
2741
cda3738a85bd
use ngx_str_t for error levels
Igor Sysoev <igor@sysoev.ru>
parents:
2737
diff
changeset
|
381 "duplicate log level \"%V\"", |
cda3738a85bd
use ngx_str_t for error levels
Igor Sysoev <igor@sysoev.ru>
parents:
2737
diff
changeset
|
382 &value[i]); |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
383 return NGX_CONF_ERROR; |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
384 } |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
385 |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
232
diff
changeset
|
386 log->log_level = n; |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
387 continue; |
207
6e0fef527732
nginx-0.0.1-2003-12-05-20:07:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
388 } |
6e0fef527732
nginx-0.0.1-2003-12-05-20:07:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
389 } |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
390 |
236
86e473b5641e
nginx-0.0.1-2004-01-22-09:47:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
235
diff
changeset
|
391 for (n = 0, d = NGX_LOG_DEBUG_FIRST; d <= NGX_LOG_DEBUG_LAST; d <<= 1) { |
86e473b5641e
nginx-0.0.1-2004-01-22-09:47:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
235
diff
changeset
|
392 if (ngx_strcmp(value[i].data, debug_levels[n++]) == 0) { |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
232
diff
changeset
|
393 if (log->log_level & ~NGX_LOG_DEBUG_ALL) { |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
394 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
2741
cda3738a85bd
use ngx_str_t for error levels
Igor Sysoev <igor@sysoev.ru>
parents:
2737
diff
changeset
|
395 "invalid log level \"%V\"", |
cda3738a85bd
use ngx_str_t for error levels
Igor Sysoev <igor@sysoev.ru>
parents:
2737
diff
changeset
|
396 &value[i]); |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
397 return NGX_CONF_ERROR; |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
398 } |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
399 |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
232
diff
changeset
|
400 log->log_level |= d; |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
401 } |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
402 } |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
403 |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
404 |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
232
diff
changeset
|
405 if (log->log_level == 0) { |
207
6e0fef527732
nginx-0.0.1-2003-12-05-20:07:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
406 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
2741
cda3738a85bd
use ngx_str_t for error levels
Igor Sysoev <igor@sysoev.ru>
parents:
2737
diff
changeset
|
407 "invalid log level \"%V\"", &value[i]); |
207
6e0fef527732
nginx-0.0.1-2003-12-05-20:07:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
408 return NGX_CONF_ERROR; |
6e0fef527732
nginx-0.0.1-2003-12-05-20:07:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
409 } |
100
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
410 } |
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
411 |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
412 if (log->log_level == NGX_LOG_DEBUG) { |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
249
diff
changeset
|
413 log->log_level = NGX_LOG_DEBUG_ALL; |
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
249
diff
changeset
|
414 } |
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
249
diff
changeset
|
415 |
100
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
416 return NGX_CONF_OK; |
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
417 } |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
418 |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
419 |
503 | 420 static char * |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
421 ngx_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
422 { |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
423 ngx_str_t *value, name; |
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
424 |
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
425 if (cf->cycle->new_log.file) { |
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
426 return "is duplicate"; |
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
427 } |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
428 |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
429 value = cf->args->elts; |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
430 |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
431 if (ngx_strcmp(value[1].data, "stderr") == 0) { |
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
432 name.len = 0; |
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
433 name.data = NULL; |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
434 |
445
f26432a1935a
nginx-0.1.0-2004-09-30-10:38:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
435 } else { |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
436 name = value[1]; |
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
437 } |
445
f26432a1935a
nginx-0.1.0-2004-09-30-10:38:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
438 |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
439 cf->cycle->new_log.file = ngx_conf_open_file(cf->cycle, &name); |
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
440 if (cf->cycle->new_log.file == NULL) { |
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
441 return NULL; |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
442 } |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
443 |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
444 if (cf->args->nelts == 2) { |
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
445 cf->cycle->new_log.log_level = NGX_LOG_ERR; |
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
446 return NGX_CONF_OK; |
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
447 } |
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
448 |
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
449 cf->cycle->new_log.log_level = 0; |
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
450 |
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
451 return ngx_log_set_levels(cf, &cf->cycle->new_log); |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
452 } |