Mercurial > hg > nginx
annotate src/core/ngx_log.c @ 4104:84f34973684c
Version bump.
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 14 Sep 2011 15:20:01 +0000 |
parents | bf452af6c1d2 |
children | d620f497c50f |
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 |
3822
75ffcfc700f3
remove semicolon, because it is already in "nginx: " prefix
Igor Sysoev <igor@sysoev.ru>
parents:
3799
diff
changeset
|
151 msg -= (7 + err_levels[level].len + 3); |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
152 |
3822
75ffcfc700f3
remove semicolon, because it is already in "nginx: " prefix
Igor Sysoev <igor@sysoev.ru>
parents:
3799
diff
changeset
|
153 (void) ngx_sprintf(msg, "nginx: [%V] ", &err_levels[level]); |
2743
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; |
3799
188007bf58c3
add "nginx: " prefix when logging to the stderr
Igor Sysoev <igor@sysoev.ru>
parents:
3787
diff
changeset
|
212 p = errstr + 7; |
188007bf58c3
add "nginx: " prefix when logging to the stderr
Igor Sysoev <igor@sysoev.ru>
parents:
3787
diff
changeset
|
213 |
188007bf58c3
add "nginx: " prefix when logging to the stderr
Igor Sysoev <igor@sysoev.ru>
parents:
3787
diff
changeset
|
214 ngx_memcpy(errstr, "nginx: ", 7); |
2764
d4a717592877
use ngx_vslprintf(), ngx_slprintf()
Igor Sysoev <igor@sysoev.ru>
parents:
2758
diff
changeset
|
215 |
2722 | 216 va_start(args, fmt); |
3799
188007bf58c3
add "nginx: " prefix when logging to the stderr
Igor Sysoev <igor@sysoev.ru>
parents:
3787
diff
changeset
|
217 p = ngx_vslprintf(p, last, fmt, args); |
2722 | 218 va_end(args); |
219 | |
2765 | 220 if (err) { |
221 p = ngx_log_errno(p, last, err); | |
2722 | 222 } |
223 | |
2765 | 224 if (p > last - NGX_LINEFEED_SIZE) { |
225 p = last - NGX_LINEFEED_SIZE; | |
2732 | 226 } |
227 | |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
228 ngx_linefeed(p); |
2732 | 229 |
2769
9d986c4e796f
introduce ngx_write_console() to support OEM code pages
Igor Sysoev <igor@sysoev.ru>
parents:
2765
diff
changeset
|
230 (void) ngx_write_console(ngx_stderr, errstr, p - errstr); |
2722 | 231 } |
232 | |
233 | |
2765 | 234 u_char * |
235 ngx_log_errno(u_char *buf, u_char *last, ngx_err_t err) | |
236 { | |
237 if (buf > last - 50) { | |
238 | |
239 /* leave a space for an error code */ | |
240 | |
241 buf = last - 50; | |
242 *buf++ = '.'; | |
243 *buf++ = '.'; | |
244 *buf++ = '.'; | |
245 } | |
246 | |
247 #if (NGX_WIN32) | |
248 buf = ngx_slprintf(buf, last, ((unsigned) err < 0x80000000) | |
249 ? " (%d: " : " (%Xd: ", err); | |
250 #else | |
251 buf = ngx_slprintf(buf, last, " (%d: ", err); | |
252 #endif | |
253 | |
3787
e294f37401c0
use copied strerror() messages and autoconfigured sys_nerr value
Igor Sysoev <igor@sysoev.ru>
parents:
3516
diff
changeset
|
254 buf = ngx_strerror(err, buf, last - buf); |
2765 | 255 |
256 if (buf < last) { | |
257 *buf++ = ')'; | |
258 } | |
259 | |
260 return buf; | |
261 } | |
262 | |
263 | |
503 | 264 ngx_log_t * |
2758 | 265 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
|
266 { |
2758 | 267 u_char *p, *name; |
268 size_t nlen, plen; | |
269 | |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
270 ngx_log.file = &ngx_log_file; |
461 | 271 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
|
272 |
2758 | 273 name = (u_char *) NGX_ERROR_LOG_PATH; |
274 | |
2743
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 * 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
|
277 * 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
|
278 */ |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
279 |
2758 | 280 nlen = ngx_strlen(name); |
281 | |
282 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
|
283 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
|
284 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
|
285 } |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
286 |
2758 | 287 p = NULL; |
288 | |
289 #if (NGX_WIN32) | |
290 if (name[1] != ':') { | |
291 #else | |
292 if (name[0] != '/') { | |
293 #endif | |
294 | |
295 if (prefix) { | |
296 plen = ngx_strlen(prefix); | |
297 | |
2773
7a44b1932741
fix building by BCC if NGX_PREFIX is defined
Igor Sysoev <igor@sysoev.ru>
parents:
2769
diff
changeset
|
298 } else { |
2758 | 299 #ifdef NGX_PREFIX |
300 prefix = (u_char *) NGX_PREFIX; | |
301 plen = ngx_strlen(prefix); | |
2773
7a44b1932741
fix building by BCC if NGX_PREFIX is defined
Igor Sysoev <igor@sysoev.ru>
parents:
2769
diff
changeset
|
302 #else |
7a44b1932741
fix building by BCC if NGX_PREFIX is defined
Igor Sysoev <igor@sysoev.ru>
parents:
2769
diff
changeset
|
303 plen = 0; |
2758 | 304 #endif |
305 } | |
306 | |
307 if (plen) { | |
308 name = malloc(plen + nlen + 2); | |
309 if (name == NULL) { | |
310 return NULL; | |
311 } | |
312 | |
313 p = ngx_cpymem(name, prefix, plen); | |
314 | |
315 if (!ngx_path_separator(*(p - 1))) { | |
316 *p++ = '/'; | |
317 } | |
318 | |
319 ngx_cpystrn(p, (u_char *) NGX_ERROR_LOG_PATH, nlen + 1); | |
320 | |
321 p = name; | |
322 } | |
323 } | |
324 | |
325 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
|
326 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
|
327 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
|
328 |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
329 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
|
330 ngx_log_stderr(ngx_errno, |
3871
8ccd6ed1d4bb
remove semicolon, because it is already in "nginx: " prefix
Igor Sysoev <igor@sysoev.ru>
parents:
3822
diff
changeset
|
331 "[alert] could not open error log file: " |
2758 | 332 ngx_open_file_n " \"%s\" failed", name); |
461 | 333 #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
|
334 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
|
335 "could not open error log file: " |
2758 | 336 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
|
337 #endif |
100
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
338 |
2758 | 339 ngx_log_file.fd = ngx_stderr; |
340 } | |
341 | |
342 if (p) { | |
343 ngx_free(p); | |
461 | 344 } |
207
6e0fef527732
nginx-0.0.1-2003-12-05-20:07:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
345 |
448
241dc8092a33
nginx-0.1.0-2004-10-01-19:53:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
445
diff
changeset
|
346 return &ngx_log; |
241dc8092a33
nginx-0.1.0-2004-10-01-19:53:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
445
diff
changeset
|
347 } |
241dc8092a33
nginx-0.1.0-2004-10-01-19:53:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
445
diff
changeset
|
348 |
241dc8092a33
nginx-0.1.0-2004-10-01-19:53:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
445
diff
changeset
|
349 |
503 | 350 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
|
351 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
|
352 { |
a9bc21d63fe4
nginx-0.0.1-2003-07-02-18:41:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
106
diff
changeset
|
353 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
|
354 |
501 | 355 log = ngx_pcalloc(cycle->pool, sizeof(ngx_log_t)); |
356 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
|
357 return NULL; |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
379
diff
changeset
|
358 } |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
379
diff
changeset
|
359 |
501 | 360 log->file = ngx_conf_open_file(cycle, name); |
361 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
|
362 return NULL; |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
379
diff
changeset
|
363 } |
119
cd54bcbaf3b5
nginx-0.0.1-2003-07-21-01:15:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
116
diff
changeset
|
364 |
109
a9bc21d63fe4
nginx-0.0.1-2003-07-02-18:41:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
106
diff
changeset
|
365 return log; |
a9bc21d63fe4
nginx-0.0.1-2003-07-02-18:41:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
106
diff
changeset
|
366 } |
a9bc21d63fe4
nginx-0.0.1-2003-07-02-18:41:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
106
diff
changeset
|
367 |
a9bc21d63fe4
nginx-0.0.1-2003-07-02-18:41:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
106
diff
changeset
|
368 |
503 | 369 char * |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
370 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
|
371 { |
4012
bf452af6c1d2
Complain on invalid log levels.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3871
diff
changeset
|
372 ngx_uint_t i, n, d, found; |
290
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
278
diff
changeset
|
373 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
|
374 |
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
232
diff
changeset
|
375 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
|
376 |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
377 for (i = 2; i < cf->args->nelts; i++) { |
4012
bf452af6c1d2
Complain on invalid log levels.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3871
diff
changeset
|
378 found = 0; |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
379 |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
249
diff
changeset
|
380 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
|
381 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
|
382 |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
232
diff
changeset
|
383 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
|
384 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
|
385 "duplicate log level \"%V\"", |
cda3738a85bd
use ngx_str_t for error levels
Igor Sysoev <igor@sysoev.ru>
parents:
2737
diff
changeset
|
386 &value[i]); |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
387 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
|
388 } |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
389 |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
232
diff
changeset
|
390 log->log_level = n; |
4012
bf452af6c1d2
Complain on invalid log levels.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3871
diff
changeset
|
391 found = 1; |
bf452af6c1d2
Complain on invalid log levels.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3871
diff
changeset
|
392 break; |
207
6e0fef527732
nginx-0.0.1-2003-12-05-20:07:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
393 } |
6e0fef527732
nginx-0.0.1-2003-12-05-20:07:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
394 } |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
395 |
236
86e473b5641e
nginx-0.0.1-2004-01-22-09:47:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
235
diff
changeset
|
396 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
|
397 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
|
398 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
|
399 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
|
400 "invalid log level \"%V\"", |
cda3738a85bd
use ngx_str_t for error levels
Igor Sysoev <igor@sysoev.ru>
parents:
2737
diff
changeset
|
401 &value[i]); |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
402 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
|
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 log->log_level |= d; |
4012
bf452af6c1d2
Complain on invalid log levels.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3871
diff
changeset
|
406 found = 1; |
bf452af6c1d2
Complain on invalid log levels.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3871
diff
changeset
|
407 break; |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
408 } |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
409 } |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
410 |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
411 |
4012
bf452af6c1d2
Complain on invalid log levels.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3871
diff
changeset
|
412 if (!found) { |
207
6e0fef527732
nginx-0.0.1-2003-12-05-20:07:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
413 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
|
414 "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
|
415 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
|
416 } |
100
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
417 } |
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
418 |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
419 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
|
420 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
|
421 } |
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
249
diff
changeset
|
422 |
100
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
423 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
|
424 } |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
425 |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
426 |
503 | 427 static char * |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
428 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
|
429 { |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
430 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
|
431 |
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
432 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
|
433 return "is duplicate"; |
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
434 } |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
435 |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
436 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
|
437 |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
438 if (ngx_strcmp(value[1].data, "stderr") == 0) { |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
2785
diff
changeset
|
439 ngx_str_null(&name); |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
440 |
445
f26432a1935a
nginx-0.1.0-2004-09-30-10:38:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
441 } else { |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
442 name = value[1]; |
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
443 } |
445
f26432a1935a
nginx-0.1.0-2004-09-30-10:38:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
444 |
2785
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.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
|
446 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
|
447 return NULL; |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
448 } |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
449 |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
450 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
|
451 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
|
452 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
|
453 } |
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
454 |
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
455 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
|
456 |
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
457 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
|
458 } |