Mercurial > hg > nginx-quic
annotate src/core/ngx_log.c @ 5431:91bd62a9627e
Core: handling of getsockopt(TCP_DEFER_ACCEPT) failures.
Recent Linux versions started to return EOPNOTSUPP to getsockopt() calls
on unix sockets, resulting in log pollution on binary upgrade. Such errors
are silently ignored now.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 31 Oct 2013 04:00:37 +0400 |
parents | e088695737c3 |
children | 777202558122 |
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 |
4412 | 4 * Copyright (C) Nginx, Inc. |
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
|
5 */ |
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
|
6 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #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
|
9 #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
|
10 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
12 static char *ngx_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
13 static char *ngx_log_set_levels(ngx_conf_t *cf, ngx_log_t *log); |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
14 static void ngx_log_insert(ngx_log_t *log, ngx_log_t *new_log); |
100
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 |
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
17 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
|
18 |
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
19 {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
|
20 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
|
21 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
|
22 0, |
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
23 0, |
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
24 NULL}, |
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 ngx_null_command |
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
27 }; |
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
28 |
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
29 |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
30 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
|
31 ngx_string("errlog"), |
577 | 32 NULL, |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
33 NULL |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
34 }; |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
35 |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
36 |
100
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
37 ngx_module_t ngx_errlog_module = { |
509 | 38 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
|
39 &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
|
40 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
|
41 NGX_CORE_MODULE, /* module type */ |
541 | 42 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
|
43 NULL, /* init module */ |
541 | 44 NULL, /* init process */ |
45 NULL, /* init thread */ | |
46 NULL, /* exit thread */ | |
47 NULL, /* exit process */ | |
48 NULL, /* exit master */ | |
49 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
|
50 }; |
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
51 |
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
52 |
415
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
379
diff
changeset
|
53 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
|
54 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
|
55 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
|
56 |
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
57 |
2741
cda3738a85bd
use ngx_str_t for error levels
Igor Sysoev <igor@sysoev.ru>
parents:
2737
diff
changeset
|
58 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
|
59 ngx_null_string, |
2741
cda3738a85bd
use ngx_str_t for error levels
Igor Sysoev <igor@sysoev.ru>
parents:
2737
diff
changeset
|
60 ngx_string("emerg"), |
cda3738a85bd
use ngx_str_t for error levels
Igor Sysoev <igor@sysoev.ru>
parents:
2737
diff
changeset
|
61 ngx_string("alert"), |
cda3738a85bd
use ngx_str_t for error levels
Igor Sysoev <igor@sysoev.ru>
parents:
2737
diff
changeset
|
62 ngx_string("crit"), |
cda3738a85bd
use ngx_str_t for error levels
Igor Sysoev <igor@sysoev.ru>
parents:
2737
diff
changeset
|
63 ngx_string("error"), |
cda3738a85bd
use ngx_str_t for error levels
Igor Sysoev <igor@sysoev.ru>
parents:
2737
diff
changeset
|
64 ngx_string("warn"), |
2742
e138f820b5dc
style fix: remove trailing spaces introduced in the previous commit
Igor Sysoev <igor@sysoev.ru>
parents:
2741
diff
changeset
|
65 ngx_string("notice"), |
e138f820b5dc
style fix: remove trailing spaces introduced in the previous commit
Igor Sysoev <igor@sysoev.ru>
parents:
2741
diff
changeset
|
66 ngx_string("info"), |
2741
cda3738a85bd
use ngx_str_t for error levels
Igor Sysoev <igor@sysoev.ru>
parents:
2737
diff
changeset
|
67 ngx_string("debug") |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
68 }; |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
69 |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
70 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
|
71 "debug_core", "debug_alloc", "debug_mutex", "debug_event", |
1136 | 72 "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
|
73 }; |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
74 |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
75 |
455 | 76 #if (NGX_HAVE_VARIADIC_MACROS) |
503 | 77 |
78 void | |
79 ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err, | |
80 const char *fmt, ...) | |
81 | |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
82 #else |
503 | 83 |
84 void | |
85 ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err, | |
86 const char *fmt, va_list args) | |
87 | |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
88 #endif |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
89 { |
455 | 90 #if (NGX_HAVE_VARIADIC_MACROS) |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
91 va_list args; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
92 #endif |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
93 u_char *p, *last, *msg; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
94 u_char errstr[NGX_MAX_ERROR_STR]; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
95 ngx_uint_t wrote_stderr, debug_connection; |
119
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 |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
142 wrote_stderr = 0; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
143 debug_connection = (log->log_level & NGX_LOG_DEBUG_CONNECTION) != 0; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
144 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
145 while (log) { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
146 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
147 if (log->log_level < level && !debug_connection) { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
148 break; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
149 } |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
150 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
151 (void) ngx_write_fd(log->file->fd, errstr, p - errstr); |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
152 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
153 if (log->file->fd == ngx_stderr) { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
154 wrote_stderr = 1; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
155 } |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
156 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
157 log = log->next; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
158 } |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
159 |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
160 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
|
161 || level > NGX_LOG_WARN |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
162 || wrote_stderr) |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
163 { |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
164 return; |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
165 } |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
166 |
3822
75ffcfc700f3
remove semicolon, because it is already in "nginx: " prefix
Igor Sysoev <igor@sysoev.ru>
parents:
3799
diff
changeset
|
167 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
|
168 |
3822
75ffcfc700f3
remove semicolon, because it is already in "nginx: " prefix
Igor Sysoev <igor@sysoev.ru>
parents:
3799
diff
changeset
|
169 (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
|
170 |
2769
9d986c4e796f
introduce ngx_write_console() to support OEM code pages
Igor Sysoev <igor@sysoev.ru>
parents:
2765
diff
changeset
|
171 (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
|
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 |
455 | 175 #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
|
176 |
503 | 177 void ngx_cdecl |
178 ngx_log_error(ngx_uint_t level, ngx_log_t *log, ngx_err_t err, | |
179 const char *fmt, ...) | |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
180 { |
461 | 181 va_list args; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
182 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
183 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
|
184 va_start(args, fmt); |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
185 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
|
186 va_end(args); |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
187 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
188 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
189 |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
83
diff
changeset
|
190 |
503 | 191 void ngx_cdecl |
192 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
|
193 { |
461 | 194 va_list args; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
195 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
196 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
|
197 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
|
198 va_end(args); |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
199 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
200 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
201 #endif |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
83
diff
changeset
|
202 |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
83
diff
changeset
|
203 |
2752
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
204 void ngx_cdecl |
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
205 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
|
206 { |
2752
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
207 u_char *p; |
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
208 va_list args; |
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
209 u_char errstr[NGX_MAX_CONF_ERRSTR]; |
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
210 |
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
211 va_start(args, fmt); |
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
212 p = ngx_vsnprintf(errstr, sizeof(errstr) - 1, fmt, args); |
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
213 va_end(args); |
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
214 |
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
215 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
|
216 "%*s", p - errstr, errstr); |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
639
diff
changeset
|
217 } |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
639
diff
changeset
|
218 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
639
diff
changeset
|
219 |
2722 | 220 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
|
221 ngx_log_stderr(ngx_err_t err, const char *fmt, ...) |
2722 | 222 { |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
223 u_char *p, *last; |
2722 | 224 va_list args; |
225 u_char errstr[NGX_MAX_ERROR_STR]; | |
226 | |
2764
d4a717592877
use ngx_vslprintf(), ngx_slprintf()
Igor Sysoev <igor@sysoev.ru>
parents:
2758
diff
changeset
|
227 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
|
228 p = errstr + 7; |
188007bf58c3
add "nginx: " prefix when logging to the stderr
Igor Sysoev <igor@sysoev.ru>
parents:
3787
diff
changeset
|
229 |
188007bf58c3
add "nginx: " prefix when logging to the stderr
Igor Sysoev <igor@sysoev.ru>
parents:
3787
diff
changeset
|
230 ngx_memcpy(errstr, "nginx: ", 7); |
2764
d4a717592877
use ngx_vslprintf(), ngx_slprintf()
Igor Sysoev <igor@sysoev.ru>
parents:
2758
diff
changeset
|
231 |
2722 | 232 va_start(args, fmt); |
3799
188007bf58c3
add "nginx: " prefix when logging to the stderr
Igor Sysoev <igor@sysoev.ru>
parents:
3787
diff
changeset
|
233 p = ngx_vslprintf(p, last, fmt, args); |
2722 | 234 va_end(args); |
235 | |
2765 | 236 if (err) { |
237 p = ngx_log_errno(p, last, err); | |
2722 | 238 } |
239 | |
2765 | 240 if (p > last - NGX_LINEFEED_SIZE) { |
241 p = last - NGX_LINEFEED_SIZE; | |
2732 | 242 } |
243 | |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
244 ngx_linefeed(p); |
2732 | 245 |
2769
9d986c4e796f
introduce ngx_write_console() to support OEM code pages
Igor Sysoev <igor@sysoev.ru>
parents:
2765
diff
changeset
|
246 (void) ngx_write_console(ngx_stderr, errstr, p - errstr); |
2722 | 247 } |
248 | |
249 | |
2765 | 250 u_char * |
251 ngx_log_errno(u_char *buf, u_char *last, ngx_err_t err) | |
252 { | |
253 if (buf > last - 50) { | |
254 | |
255 /* leave a space for an error code */ | |
256 | |
257 buf = last - 50; | |
258 *buf++ = '.'; | |
259 *buf++ = '.'; | |
260 *buf++ = '.'; | |
261 } | |
262 | |
263 #if (NGX_WIN32) | |
264 buf = ngx_slprintf(buf, last, ((unsigned) err < 0x80000000) | |
265 ? " (%d: " : " (%Xd: ", err); | |
266 #else | |
267 buf = ngx_slprintf(buf, last, " (%d: ", err); | |
268 #endif | |
269 | |
3787
e294f37401c0
use copied strerror() messages and autoconfigured sys_nerr value
Igor Sysoev <igor@sysoev.ru>
parents:
3516
diff
changeset
|
270 buf = ngx_strerror(err, buf, last - buf); |
2765 | 271 |
272 if (buf < last) { | |
273 *buf++ = ')'; | |
274 } | |
275 | |
276 return buf; | |
277 } | |
278 | |
279 | |
503 | 280 ngx_log_t * |
2758 | 281 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
|
282 { |
2758 | 283 u_char *p, *name; |
284 size_t nlen, plen; | |
285 | |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
286 ngx_log.file = &ngx_log_file; |
461 | 287 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
|
288 |
2758 | 289 name = (u_char *) NGX_ERROR_LOG_PATH; |
290 | |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
291 /* |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
292 * 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
|
293 * 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
|
294 */ |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
295 |
2758 | 296 nlen = ngx_strlen(name); |
297 | |
298 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
|
299 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
|
300 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
|
301 } |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
302 |
2758 | 303 p = NULL; |
304 | |
305 #if (NGX_WIN32) | |
306 if (name[1] != ':') { | |
307 #else | |
308 if (name[0] != '/') { | |
309 #endif | |
310 | |
311 if (prefix) { | |
312 plen = ngx_strlen(prefix); | |
313 | |
2773
7a44b1932741
fix building by BCC if NGX_PREFIX is defined
Igor Sysoev <igor@sysoev.ru>
parents:
2769
diff
changeset
|
314 } else { |
2758 | 315 #ifdef NGX_PREFIX |
316 prefix = (u_char *) NGX_PREFIX; | |
317 plen = ngx_strlen(prefix); | |
2773
7a44b1932741
fix building by BCC if NGX_PREFIX is defined
Igor Sysoev <igor@sysoev.ru>
parents:
2769
diff
changeset
|
318 #else |
7a44b1932741
fix building by BCC if NGX_PREFIX is defined
Igor Sysoev <igor@sysoev.ru>
parents:
2769
diff
changeset
|
319 plen = 0; |
2758 | 320 #endif |
321 } | |
322 | |
323 if (plen) { | |
324 name = malloc(plen + nlen + 2); | |
325 if (name == NULL) { | |
326 return NULL; | |
327 } | |
328 | |
329 p = ngx_cpymem(name, prefix, plen); | |
330 | |
331 if (!ngx_path_separator(*(p - 1))) { | |
332 *p++ = '/'; | |
333 } | |
334 | |
335 ngx_cpystrn(p, (u_char *) NGX_ERROR_LOG_PATH, nlen + 1); | |
336 | |
337 p = name; | |
338 } | |
339 } | |
340 | |
341 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
|
342 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
|
343 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
|
344 |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
345 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
|
346 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
|
347 "[alert] could not open error log file: " |
2758 | 348 ngx_open_file_n " \"%s\" failed", name); |
461 | 349 #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
|
350 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
|
351 "could not open error log file: " |
2758 | 352 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
|
353 #endif |
100
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
354 |
2758 | 355 ngx_log_file.fd = ngx_stderr; |
356 } | |
357 | |
358 if (p) { | |
359 ngx_free(p); | |
461 | 360 } |
207
6e0fef527732
nginx-0.0.1-2003-12-05-20:07:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
361 |
448
241dc8092a33
nginx-0.1.0-2004-10-01-19:53:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
445
diff
changeset
|
362 return &ngx_log; |
241dc8092a33
nginx-0.1.0-2004-10-01-19:53:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
445
diff
changeset
|
363 } |
241dc8092a33
nginx-0.1.0-2004-10-01-19:53:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
445
diff
changeset
|
364 |
241dc8092a33
nginx-0.1.0-2004-10-01-19:53:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
445
diff
changeset
|
365 |
5260
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
366 ngx_int_t |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
367 ngx_log_open_default(ngx_cycle_t *cycle) |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
368 { |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
369 static ngx_str_t error_log = ngx_string(NGX_ERROR_LOG_PATH); |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
370 |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
371 if (cycle->new_log.file == NULL) { |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
372 cycle->new_log.file = ngx_conf_open_file(cycle, &error_log); |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
373 if (cycle->new_log.file == NULL) { |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
374 return NGX_ERROR; |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
375 } |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
376 |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
377 cycle->new_log.log_level = NGX_LOG_ERR; |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
378 } |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
379 |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
380 return NGX_OK; |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
381 } |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
382 |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
383 |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
384 ngx_int_t |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
385 ngx_log_redirect_stderr(ngx_cycle_t *cycle) |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
386 { |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
387 ngx_fd_t fd; |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
388 |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
389 if (cycle->log_use_stderr) { |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
390 return NGX_OK; |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
391 } |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
392 |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
393 fd = cycle->log->file->fd; |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
394 |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
395 if (fd != ngx_stderr) { |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
396 if (ngx_set_stderr(fd) == NGX_FILE_ERROR) { |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
397 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
398 ngx_set_stderr_n " failed"); |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
399 |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
400 return NGX_ERROR; |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
401 } |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
402 } |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
403 |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
404 return NGX_OK; |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
405 } |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
406 |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
407 |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
408 static char * |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
409 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
|
410 { |
4012
bf452af6c1d2
Complain on invalid log levels.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3871
diff
changeset
|
411 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
|
412 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
|
413 |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
414 if (cf->args->nelts == 2) { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
415 log->log_level = NGX_LOG_ERR; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
416 return NGX_CONF_OK; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
417 } |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
418 |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
232
diff
changeset
|
419 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
|
420 |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
421 for (i = 2; i < cf->args->nelts; i++) { |
4012
bf452af6c1d2
Complain on invalid log levels.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3871
diff
changeset
|
422 found = 0; |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
423 |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
249
diff
changeset
|
424 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
|
425 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
|
426 |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
232
diff
changeset
|
427 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
|
428 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
|
429 "duplicate log level \"%V\"", |
cda3738a85bd
use ngx_str_t for error levels
Igor Sysoev <igor@sysoev.ru>
parents:
2737
diff
changeset
|
430 &value[i]); |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
431 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
|
432 } |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
433 |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
232
diff
changeset
|
434 log->log_level = n; |
4012
bf452af6c1d2
Complain on invalid log levels.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3871
diff
changeset
|
435 found = 1; |
bf452af6c1d2
Complain on invalid log levels.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3871
diff
changeset
|
436 break; |
207
6e0fef527732
nginx-0.0.1-2003-12-05-20:07:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
437 } |
6e0fef527732
nginx-0.0.1-2003-12-05-20:07:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
438 } |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
439 |
236
86e473b5641e
nginx-0.0.1-2004-01-22-09:47:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
235
diff
changeset
|
440 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
|
441 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
|
442 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
|
443 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
|
444 "invalid log level \"%V\"", |
cda3738a85bd
use ngx_str_t for error levels
Igor Sysoev <igor@sysoev.ru>
parents:
2737
diff
changeset
|
445 &value[i]); |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
446 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
|
447 } |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
448 |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
232
diff
changeset
|
449 log->log_level |= d; |
4012
bf452af6c1d2
Complain on invalid log levels.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3871
diff
changeset
|
450 found = 1; |
bf452af6c1d2
Complain on invalid log levels.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3871
diff
changeset
|
451 break; |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
452 } |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
453 } |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
454 |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
455 |
4012
bf452af6c1d2
Complain on invalid log levels.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3871
diff
changeset
|
456 if (!found) { |
207
6e0fef527732
nginx-0.0.1-2003-12-05-20:07:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
457 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
|
458 "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
|
459 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
|
460 } |
100
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
461 } |
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
462 |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
463 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
|
464 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
|
465 } |
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
249
diff
changeset
|
466 |
100
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
467 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
|
468 } |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
469 |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
470 |
503 | 471 static char * |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
472 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
|
473 { |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
474 ngx_log_t *dummy; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
475 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
476 dummy = &cf->cycle->new_log; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
477 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
478 return ngx_log_set_log(cf, &dummy); |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
479 } |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
480 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
481 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
482 char * |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
483 ngx_log_set_log(ngx_conf_t *cf, ngx_log_t **head) |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
484 { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
485 ngx_log_t *new_log; |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
486 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
|
487 |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
488 if (*head != NULL && (*head)->log_level == 0) { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
489 new_log = *head; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
490 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
491 } else { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
492 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
493 new_log = ngx_pcalloc(cf->pool, sizeof(ngx_log_t)); |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
494 if (new_log == NULL) { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
495 return NGX_CONF_ERROR; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
496 } |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
497 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
498 if (*head == NULL) { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
499 *head = new_log; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
500 } |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
501 } |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
502 |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
503 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
|
504 |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
505 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
|
506 ngx_str_null(&name); |
5240
d8af1005e886
Core: fixed handling of "stderr" in error_log.
Vladimir Homutov <vl@nginx.com>
parents:
4412
diff
changeset
|
507 cf->cycle->log_use_stderr = 1; |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
508 |
445
f26432a1935a
nginx-0.1.0-2004-09-30-10:38:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
509 } else { |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
510 name = value[1]; |
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
511 } |
445
f26432a1935a
nginx-0.1.0-2004-09-30-10:38:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
512 |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
513 new_log->file = ngx_conf_open_file(cf->cycle, &name); |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
514 if (new_log->file == NULL) { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
515 return NGX_CONF_ERROR; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
516 } |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
517 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
518 if (ngx_log_set_levels(cf, new_log) != NGX_CONF_OK) { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
519 return NGX_CONF_ERROR; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
520 } |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
521 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
522 if (*head != new_log) { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
523 ngx_log_insert(*head, new_log); |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
524 } |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
525 |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
526 return NGX_CONF_OK; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
527 } |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
528 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
529 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
530 static void |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
531 ngx_log_insert(ngx_log_t *log, ngx_log_t *new_log) |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
532 { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
533 ngx_log_t tmp; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
534 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
535 if (new_log->log_level > log->log_level) { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
536 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
537 /* |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
538 * list head address is permanent, insert new log after |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
539 * head and swap its contents with head |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
540 */ |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
541 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
542 tmp = *log; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
543 *log = *new_log; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
544 *new_log = tmp; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
545 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
546 log->next = new_log; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
547 return; |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
548 } |
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
549 |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
550 while (log->next) { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
551 if (new_log->log_level > log->next->log_level) { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
552 new_log->next = log->next; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
553 log->next = new_log; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
554 return; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
555 } |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
556 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
557 log = log->next; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
558 } |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
559 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
560 log->next = new_log; |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
561 } |