Mercurial > hg > nginx-quic
annotate src/core/ngx_log.c @ 6020:e5f1d83360ef
Events: implemented kqueue notification mechanism.
author | Valentin Bartenev <vbart@nginx.com> |
---|---|
date | Sat, 14 Mar 2015 17:37:16 +0300 |
parents | 93fee708f168 |
children | 8e66a83d16ae |
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; |
5962
727177743c3c
Core: added disk_full_time checks to error log.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5771
diff
changeset
|
94 ssize_t n; |
727177743c3c
Core: added disk_full_time checks to error log.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5771
diff
changeset
|
95 ngx_uint_t wrote_stderr, debug_connection; |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
96 u_char errstr[NGX_MAX_ERROR_STR]; |
119
cd54bcbaf3b5
nginx-0.0.1-2003-07-21-01:15:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
116
diff
changeset
|
97 |
461 | 98 last = errstr + NGX_MAX_ERROR_STR; |
99 | |
6000
93fee708f168
Log: use ngx_cpymem() in a couple of places, no functional changes.
Valentin Bartenev <vbart@nginx.com>
parents:
5962
diff
changeset
|
100 p = ngx_cpymem(errstr, ngx_cached_err_log_time.data, |
93fee708f168
Log: use ngx_cpymem() in a couple of places, no functional changes.
Valentin Bartenev <vbart@nginx.com>
parents:
5962
diff
changeset
|
101 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
|
102 |
2764
d4a717592877
use ngx_vslprintf(), ngx_slprintf()
Igor Sysoev <igor@sysoev.ru>
parents:
2758
diff
changeset
|
103 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
|
104 |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
28
diff
changeset
|
105 /* pid#tid */ |
2764
d4a717592877
use ngx_vslprintf(), ngx_slprintf()
Igor Sysoev <igor@sysoev.ru>
parents:
2758
diff
changeset
|
106 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
|
107 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
|
108 |
483 | 109 if (log->connection) { |
2764
d4a717592877
use ngx_vslprintf(), ngx_slprintf()
Igor Sysoev <igor@sysoev.ru>
parents:
2758
diff
changeset
|
110 p = ngx_slprintf(p, last, "*%uA ", log->connection); |
483 | 111 } |
112 | |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
113 msg = p; |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
114 |
455 | 115 #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
|
116 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
117 va_start(args, fmt); |
2764
d4a717592877
use ngx_vslprintf(), ngx_slprintf()
Igor Sysoev <igor@sysoev.ru>
parents:
2758
diff
changeset
|
118 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
|
119 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
|
120 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
121 #else |
191
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
186
diff
changeset
|
122 |
2764
d4a717592877
use ngx_vslprintf(), ngx_slprintf()
Igor Sysoev <igor@sysoev.ru>
parents:
2758
diff
changeset
|
123 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
|
124 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
125 #endif |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
126 |
6
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
127 if (err) { |
2765 | 128 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
|
129 } |
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
130 |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
28
diff
changeset
|
131 if (level != NGX_LOG_DEBUG && log->handler) { |
483 | 132 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
|
133 } |
6
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
134 |
571 | 135 if (p > last - NGX_LINEFEED_SIZE) { |
136 p = last - NGX_LINEFEED_SIZE; | |
461 | 137 } |
138 | |
571 | 139 ngx_linefeed(p); |
467 | 140 |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
141 wrote_stderr = 0; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
142 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
|
143 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
144 while (log) { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
145 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
146 if (log->log_level < level && !debug_connection) { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
147 break; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
148 } |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
149 |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
150 if (log->writer) { |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
151 log->writer(log, level, errstr, p - errstr); |
5962
727177743c3c
Core: added disk_full_time checks to error log.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5771
diff
changeset
|
152 goto next; |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
153 } |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
154 |
5962
727177743c3c
Core: added disk_full_time checks to error log.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5771
diff
changeset
|
155 if (ngx_time() == log->disk_full_time) { |
727177743c3c
Core: added disk_full_time checks to error log.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5771
diff
changeset
|
156 |
727177743c3c
Core: added disk_full_time checks to error log.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5771
diff
changeset
|
157 /* |
727177743c3c
Core: added disk_full_time checks to error log.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5771
diff
changeset
|
158 * on FreeBSD writing to a full filesystem with enabled softupdates |
727177743c3c
Core: added disk_full_time checks to error log.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5771
diff
changeset
|
159 * may block process for much longer time than writing to non-full |
727177743c3c
Core: added disk_full_time checks to error log.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5771
diff
changeset
|
160 * filesystem, so we skip writing to a log for one second |
727177743c3c
Core: added disk_full_time checks to error log.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5771
diff
changeset
|
161 */ |
727177743c3c
Core: added disk_full_time checks to error log.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5771
diff
changeset
|
162 |
727177743c3c
Core: added disk_full_time checks to error log.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5771
diff
changeset
|
163 goto next; |
727177743c3c
Core: added disk_full_time checks to error log.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5771
diff
changeset
|
164 } |
727177743c3c
Core: added disk_full_time checks to error log.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5771
diff
changeset
|
165 |
727177743c3c
Core: added disk_full_time checks to error log.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5771
diff
changeset
|
166 n = ngx_write_fd(log->file->fd, errstr, p - errstr); |
727177743c3c
Core: added disk_full_time checks to error log.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5771
diff
changeset
|
167 |
727177743c3c
Core: added disk_full_time checks to error log.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5771
diff
changeset
|
168 if (n == -1 && ngx_errno == NGX_ENOSPC) { |
727177743c3c
Core: added disk_full_time checks to error log.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5771
diff
changeset
|
169 log->disk_full_time = ngx_time(); |
727177743c3c
Core: added disk_full_time checks to error log.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5771
diff
changeset
|
170 } |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
171 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
172 if (log->file->fd == ngx_stderr) { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
173 wrote_stderr = 1; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
174 } |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
175 |
5962
727177743c3c
Core: added disk_full_time checks to error log.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5771
diff
changeset
|
176 next: |
727177743c3c
Core: added disk_full_time checks to error log.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5771
diff
changeset
|
177 |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
178 log = log->next; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
179 } |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
180 |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
181 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
|
182 || level > NGX_LOG_WARN |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
183 || 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
|
184 { |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
185 return; |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
186 } |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
187 |
3822
75ffcfc700f3
remove semicolon, because it is already in "nginx: " prefix
Igor Sysoev <igor@sysoev.ru>
parents:
3799
diff
changeset
|
188 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
|
189 |
3822
75ffcfc700f3
remove semicolon, because it is already in "nginx: " prefix
Igor Sysoev <igor@sysoev.ru>
parents:
3799
diff
changeset
|
190 (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
|
191 |
2769
9d986c4e796f
introduce ngx_write_console() to support OEM code pages
Igor Sysoev <igor@sysoev.ru>
parents:
2765
diff
changeset
|
192 (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
|
193 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
194 |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
83
diff
changeset
|
195 |
455 | 196 #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
|
197 |
503 | 198 void ngx_cdecl |
199 ngx_log_error(ngx_uint_t level, ngx_log_t *log, ngx_err_t err, | |
200 const char *fmt, ...) | |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
201 { |
461 | 202 va_list args; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
203 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
204 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
|
205 va_start(args, fmt); |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
206 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
|
207 va_end(args); |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
208 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
209 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
210 |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
83
diff
changeset
|
211 |
503 | 212 void ngx_cdecl |
213 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
|
214 { |
461 | 215 va_list args; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
216 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
217 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
|
218 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
|
219 va_end(args); |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
220 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
221 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
222 #endif |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
83
diff
changeset
|
223 |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
83
diff
changeset
|
224 |
2752
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
225 void ngx_cdecl |
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
226 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
|
227 { |
2752
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
228 u_char *p; |
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
229 va_list args; |
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
230 u_char errstr[NGX_MAX_CONF_ERRSTR]; |
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
231 |
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
232 va_start(args, fmt); |
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
233 p = ngx_vsnprintf(errstr, sizeof(errstr) - 1, fmt, args); |
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
234 va_end(args); |
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
235 |
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
236 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
|
237 "%*s", p - errstr, errstr); |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
639
diff
changeset
|
238 } |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
639
diff
changeset
|
239 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
639
diff
changeset
|
240 |
2722 | 241 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
|
242 ngx_log_stderr(ngx_err_t err, const char *fmt, ...) |
2722 | 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 u_char *p, *last; |
2722 | 245 va_list args; |
246 u_char errstr[NGX_MAX_ERROR_STR]; | |
247 | |
2764
d4a717592877
use ngx_vslprintf(), ngx_slprintf()
Igor Sysoev <igor@sysoev.ru>
parents:
2758
diff
changeset
|
248 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
|
249 |
6000
93fee708f168
Log: use ngx_cpymem() in a couple of places, no functional changes.
Valentin Bartenev <vbart@nginx.com>
parents:
5962
diff
changeset
|
250 p = ngx_cpymem(errstr, "nginx: ", 7); |
2764
d4a717592877
use ngx_vslprintf(), ngx_slprintf()
Igor Sysoev <igor@sysoev.ru>
parents:
2758
diff
changeset
|
251 |
2722 | 252 va_start(args, fmt); |
3799
188007bf58c3
add "nginx: " prefix when logging to the stderr
Igor Sysoev <igor@sysoev.ru>
parents:
3787
diff
changeset
|
253 p = ngx_vslprintf(p, last, fmt, args); |
2722 | 254 va_end(args); |
255 | |
2765 | 256 if (err) { |
257 p = ngx_log_errno(p, last, err); | |
2722 | 258 } |
259 | |
2765 | 260 if (p > last - NGX_LINEFEED_SIZE) { |
261 p = last - NGX_LINEFEED_SIZE; | |
2732 | 262 } |
263 | |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
264 ngx_linefeed(p); |
2732 | 265 |
2769
9d986c4e796f
introduce ngx_write_console() to support OEM code pages
Igor Sysoev <igor@sysoev.ru>
parents:
2765
diff
changeset
|
266 (void) ngx_write_console(ngx_stderr, errstr, p - errstr); |
2722 | 267 } |
268 | |
269 | |
2765 | 270 u_char * |
271 ngx_log_errno(u_char *buf, u_char *last, ngx_err_t err) | |
272 { | |
273 if (buf > last - 50) { | |
274 | |
275 /* leave a space for an error code */ | |
276 | |
277 buf = last - 50; | |
278 *buf++ = '.'; | |
279 *buf++ = '.'; | |
280 *buf++ = '.'; | |
281 } | |
282 | |
283 #if (NGX_WIN32) | |
284 buf = ngx_slprintf(buf, last, ((unsigned) err < 0x80000000) | |
285 ? " (%d: " : " (%Xd: ", err); | |
286 #else | |
287 buf = ngx_slprintf(buf, last, " (%d: ", err); | |
288 #endif | |
289 | |
3787
e294f37401c0
use copied strerror() messages and autoconfigured sys_nerr value
Igor Sysoev <igor@sysoev.ru>
parents:
3516
diff
changeset
|
290 buf = ngx_strerror(err, buf, last - buf); |
2765 | 291 |
292 if (buf < last) { | |
293 *buf++ = ')'; | |
294 } | |
295 | |
296 return buf; | |
297 } | |
298 | |
299 | |
503 | 300 ngx_log_t * |
2758 | 301 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
|
302 { |
2758 | 303 u_char *p, *name; |
304 size_t nlen, plen; | |
305 | |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
306 ngx_log.file = &ngx_log_file; |
461 | 307 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
|
308 |
2758 | 309 name = (u_char *) NGX_ERROR_LOG_PATH; |
310 | |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
311 /* |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
312 * 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
|
313 * 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
|
314 */ |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
315 |
2758 | 316 nlen = ngx_strlen(name); |
317 | |
318 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
|
319 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
|
320 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
|
321 } |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
322 |
2758 | 323 p = NULL; |
324 | |
325 #if (NGX_WIN32) | |
326 if (name[1] != ':') { | |
327 #else | |
328 if (name[0] != '/') { | |
329 #endif | |
330 | |
331 if (prefix) { | |
332 plen = ngx_strlen(prefix); | |
333 | |
2773
7a44b1932741
fix building by BCC if NGX_PREFIX is defined
Igor Sysoev <igor@sysoev.ru>
parents:
2769
diff
changeset
|
334 } else { |
2758 | 335 #ifdef NGX_PREFIX |
336 prefix = (u_char *) NGX_PREFIX; | |
337 plen = ngx_strlen(prefix); | |
2773
7a44b1932741
fix building by BCC if NGX_PREFIX is defined
Igor Sysoev <igor@sysoev.ru>
parents:
2769
diff
changeset
|
338 #else |
7a44b1932741
fix building by BCC if NGX_PREFIX is defined
Igor Sysoev <igor@sysoev.ru>
parents:
2769
diff
changeset
|
339 plen = 0; |
2758 | 340 #endif |
341 } | |
342 | |
343 if (plen) { | |
344 name = malloc(plen + nlen + 2); | |
345 if (name == NULL) { | |
346 return NULL; | |
347 } | |
348 | |
349 p = ngx_cpymem(name, prefix, plen); | |
350 | |
351 if (!ngx_path_separator(*(p - 1))) { | |
352 *p++ = '/'; | |
353 } | |
354 | |
355 ngx_cpystrn(p, (u_char *) NGX_ERROR_LOG_PATH, nlen + 1); | |
356 | |
357 p = name; | |
358 } | |
359 } | |
360 | |
361 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
|
362 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
|
363 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
|
364 |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
365 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
|
366 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
|
367 "[alert] could not open error log file: " |
2758 | 368 ngx_open_file_n " \"%s\" failed", name); |
461 | 369 #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
|
370 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
|
371 "could not open error log file: " |
2758 | 372 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
|
373 #endif |
100
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
374 |
2758 | 375 ngx_log_file.fd = ngx_stderr; |
376 } | |
377 | |
378 if (p) { | |
379 ngx_free(p); | |
461 | 380 } |
207
6e0fef527732
nginx-0.0.1-2003-12-05-20:07:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
381 |
448
241dc8092a33
nginx-0.1.0-2004-10-01-19:53:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
445
diff
changeset
|
382 return &ngx_log; |
241dc8092a33
nginx-0.1.0-2004-10-01-19:53:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
445
diff
changeset
|
383 } |
241dc8092a33
nginx-0.1.0-2004-10-01-19:53:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
445
diff
changeset
|
384 |
241dc8092a33
nginx-0.1.0-2004-10-01-19:53:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
445
diff
changeset
|
385 |
5260
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
386 ngx_int_t |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
387 ngx_log_open_default(ngx_cycle_t *cycle) |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
388 { |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
389 ngx_log_t *log; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
390 static ngx_str_t error_log = ngx_string(NGX_ERROR_LOG_PATH); |
5260
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
391 |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
392 if (ngx_log_get_file_log(&cycle->new_log) != NULL) { |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
393 return NGX_OK; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
394 } |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
395 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
396 if (cycle->new_log.log_level != 0) { |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
397 /* there are some error logs, but no files */ |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
398 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
399 log = ngx_pcalloc(cycle->pool, sizeof(ngx_log_t)); |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
400 if (log == NULL) { |
5260
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
401 return NGX_ERROR; |
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 |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
404 } else { |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
405 /* no error logs at all */ |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
406 log = &cycle->new_log; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
407 } |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
408 |
5771
c3b08217f2a2
Core: fixed default log initialization.
Vladimir Homutov <vl@nginx.com>
parents:
5702
diff
changeset
|
409 log->log_level = NGX_LOG_ERR; |
c3b08217f2a2
Core: fixed default log initialization.
Vladimir Homutov <vl@nginx.com>
parents:
5702
diff
changeset
|
410 |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
411 log->file = ngx_conf_open_file(cycle, &error_log); |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
412 if (log->file == NULL) { |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
413 return NGX_ERROR; |
5260
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
414 } |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
415 |
5771
c3b08217f2a2
Core: fixed default log initialization.
Vladimir Homutov <vl@nginx.com>
parents:
5702
diff
changeset
|
416 if (log != &cycle->new_log) { |
c3b08217f2a2
Core: fixed default log initialization.
Vladimir Homutov <vl@nginx.com>
parents:
5702
diff
changeset
|
417 ngx_log_insert(&cycle->new_log, log); |
c3b08217f2a2
Core: fixed default log initialization.
Vladimir Homutov <vl@nginx.com>
parents:
5702
diff
changeset
|
418 } |
c3b08217f2a2
Core: fixed default log initialization.
Vladimir Homutov <vl@nginx.com>
parents:
5702
diff
changeset
|
419 |
5260
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
420 return NGX_OK; |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
421 } |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
422 |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
423 |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
424 ngx_int_t |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
425 ngx_log_redirect_stderr(ngx_cycle_t *cycle) |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
426 { |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
427 ngx_fd_t fd; |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
428 |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
429 if (cycle->log_use_stderr) { |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
430 return NGX_OK; |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
431 } |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
432 |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
433 /* file log always exists when we are called */ |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
434 fd = ngx_log_get_file_log(cycle->log)->file->fd; |
5260
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
435 |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
436 if (fd != ngx_stderr) { |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
437 if (ngx_set_stderr(fd) == NGX_FILE_ERROR) { |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
438 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
|
439 ngx_set_stderr_n " failed"); |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
440 |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
441 return NGX_ERROR; |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
442 } |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
443 } |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
444 |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
445 return NGX_OK; |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
446 } |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
447 |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
448 |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
449 ngx_log_t * |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
450 ngx_log_get_file_log(ngx_log_t *head) |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
451 { |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
452 ngx_log_t *log; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
453 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
454 for (log = head; log; log = log->next) { |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
455 if (log->file != NULL) { |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
456 return log; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
457 } |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
458 } |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
459 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
460 return NULL; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
461 } |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
462 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
463 |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
464 static char * |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
465 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
|
466 { |
4012
bf452af6c1d2
Complain on invalid log levels.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3871
diff
changeset
|
467 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
|
468 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
|
469 |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
470 if (cf->args->nelts == 2) { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
471 log->log_level = NGX_LOG_ERR; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
472 return NGX_CONF_OK; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
473 } |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
474 |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
232
diff
changeset
|
475 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
|
476 |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
477 for (i = 2; i < cf->args->nelts; i++) { |
4012
bf452af6c1d2
Complain on invalid log levels.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3871
diff
changeset
|
478 found = 0; |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
479 |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
249
diff
changeset
|
480 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
|
481 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
|
482 |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
232
diff
changeset
|
483 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
|
484 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
|
485 "duplicate log level \"%V\"", |
cda3738a85bd
use ngx_str_t for error levels
Igor Sysoev <igor@sysoev.ru>
parents:
2737
diff
changeset
|
486 &value[i]); |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
487 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
|
488 } |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
489 |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
232
diff
changeset
|
490 log->log_level = n; |
4012
bf452af6c1d2
Complain on invalid log levels.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3871
diff
changeset
|
491 found = 1; |
bf452af6c1d2
Complain on invalid log levels.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3871
diff
changeset
|
492 break; |
207
6e0fef527732
nginx-0.0.1-2003-12-05-20:07:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
493 } |
6e0fef527732
nginx-0.0.1-2003-12-05-20:07:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
494 } |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
495 |
236
86e473b5641e
nginx-0.0.1-2004-01-22-09:47:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
235
diff
changeset
|
496 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
|
497 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
|
498 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
|
499 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
|
500 "invalid log level \"%V\"", |
cda3738a85bd
use ngx_str_t for error levels
Igor Sysoev <igor@sysoev.ru>
parents:
2737
diff
changeset
|
501 &value[i]); |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
502 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
|
503 } |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
504 |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
232
diff
changeset
|
505 log->log_level |= d; |
4012
bf452af6c1d2
Complain on invalid log levels.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3871
diff
changeset
|
506 found = 1; |
bf452af6c1d2
Complain on invalid log levels.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3871
diff
changeset
|
507 break; |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
508 } |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
509 } |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
510 |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
511 |
4012
bf452af6c1d2
Complain on invalid log levels.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3871
diff
changeset
|
512 if (!found) { |
207
6e0fef527732
nginx-0.0.1-2003-12-05-20:07:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
513 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
|
514 "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
|
515 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
|
516 } |
100
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
517 } |
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
518 |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
519 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
|
520 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
|
521 } |
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
249
diff
changeset
|
522 |
100
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
523 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
|
524 } |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
525 |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
526 |
503 | 527 static char * |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
528 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
|
529 { |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
530 ngx_log_t *dummy; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
531 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
532 dummy = &cf->cycle->new_log; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
533 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
534 return ngx_log_set_log(cf, &dummy); |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
535 } |
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 char * |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
539 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
|
540 { |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
541 ngx_log_t *new_log; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
542 ngx_str_t *value, name; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
543 ngx_syslog_peer_t *peer; |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
544 |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
545 if (*head != NULL && (*head)->log_level == 0) { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
546 new_log = *head; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
547 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
548 } else { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
549 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
550 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
|
551 if (new_log == NULL) { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
552 return NGX_CONF_ERROR; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
553 } |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
554 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
555 if (*head == NULL) { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
556 *head = new_log; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
557 } |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
558 } |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
559 |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
560 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
|
561 |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
562 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
|
563 ngx_str_null(&name); |
5240
d8af1005e886
Core: fixed handling of "stderr" in error_log.
Vladimir Homutov <vl@nginx.com>
parents:
4412
diff
changeset
|
564 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
|
565 |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
566 new_log->file = ngx_conf_open_file(cf->cycle, &name); |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
567 if (new_log->file == NULL) { |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
568 return NGX_CONF_ERROR; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
569 } |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
570 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
571 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
572 } else if (ngx_strncmp(value[1].data, "syslog:", 7) == 0) { |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
573 peer = ngx_pcalloc(cf->pool, sizeof(ngx_syslog_peer_t)); |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
574 if (peer == NULL) { |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
575 return NGX_CONF_ERROR; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
576 } |
445
f26432a1935a
nginx-0.1.0-2004-09-30-10:38:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
577 |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
578 if (ngx_syslog_process_conf(cf, peer) != NGX_CONF_OK) { |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
579 return NGX_CONF_ERROR; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
580 } |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
581 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
582 new_log->writer = ngx_syslog_writer; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
583 new_log->wdata = peer; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
584 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
585 } else { |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
586 new_log->file = ngx_conf_open_file(cf->cycle, &value[1]); |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
587 if (new_log->file == NULL) { |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
588 return NGX_CONF_ERROR; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
589 } |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
590 } |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
591 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
592 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
|
593 return NGX_CONF_ERROR; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
594 } |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
595 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
596 if (*head != new_log) { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
597 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
|
598 } |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
599 |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
600 return NGX_CONF_OK; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
601 } |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
602 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
603 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
604 static void |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
605 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
|
606 { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
607 ngx_log_t tmp; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
608 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
609 if (new_log->log_level > log->log_level) { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
610 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
611 /* |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
612 * 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
|
613 * head and swap its contents with head |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
614 */ |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
615 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
616 tmp = *log; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
617 *log = *new_log; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
618 *new_log = tmp; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
619 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
620 log->next = new_log; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
621 return; |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
622 } |
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
623 |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
624 while (log->next) { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
625 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
|
626 new_log->next = log->next; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
627 log->next = new_log; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
628 return; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
629 } |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
630 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
631 log = log->next; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
632 } |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
633 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
634 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
|
635 } |