Mercurial > hg > nginx-quic
annotate src/core/ngx_log.c @ 8114:526dddf637bb
HTTP/2: run posted requests after reading body.
HTTP/2 code failed to run posted requests after calling the request body
handler, and this resulted in connection hang if a subrequest was created
in the body handler and no other actions were made.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Wed, 23 Sep 2020 19:52:31 +0300 |
parents | 4b420f9c4c5d |
children | f18db38a9826 |
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 |
6033
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
17 #if (NGX_DEBUG) |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
18 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
19 static void ngx_log_memory_writer(ngx_log_t *log, ngx_uint_t level, |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
20 u_char *buf, size_t len); |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
21 static void ngx_log_memory_cleanup(void *data); |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
22 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
23 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
24 typedef struct { |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
25 u_char *start; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
26 u_char *end; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
27 u_char *pos; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
28 ngx_atomic_t written; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
29 } ngx_log_memory_buf_t; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
30 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
31 #endif |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
32 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
33 |
100
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
34 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
|
35 |
6474 | 36 { ngx_string("error_log"), |
37 NGX_MAIN_CONF|NGX_CONF_1MORE, | |
38 ngx_error_log, | |
39 0, | |
40 0, | |
41 NULL }, | |
100
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
42 |
6474 | 43 ngx_null_command |
100
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
44 }; |
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
45 |
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
46 |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
47 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
|
48 ngx_string("errlog"), |
577 | 49 NULL, |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
50 NULL |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
51 }; |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
52 |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
53 |
100
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
54 ngx_module_t ngx_errlog_module = { |
509 | 55 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
|
56 &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
|
57 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
|
58 NGX_CORE_MODULE, /* module type */ |
541 | 59 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
|
60 NULL, /* init module */ |
541 | 61 NULL, /* init process */ |
62 NULL, /* init thread */ | |
63 NULL, /* exit thread */ | |
64 NULL, /* exit process */ | |
65 NULL, /* exit master */ | |
66 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
|
67 }; |
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
68 |
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
69 |
415
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
379
diff
changeset
|
70 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
|
71 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
|
72 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
|
73 |
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
74 |
2741
cda3738a85bd
use ngx_str_t for error levels
Igor Sysoev <igor@sysoev.ru>
parents:
2737
diff
changeset
|
75 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
|
76 ngx_null_string, |
2741
cda3738a85bd
use ngx_str_t for error levels
Igor Sysoev <igor@sysoev.ru>
parents:
2737
diff
changeset
|
77 ngx_string("emerg"), |
cda3738a85bd
use ngx_str_t for error levels
Igor Sysoev <igor@sysoev.ru>
parents:
2737
diff
changeset
|
78 ngx_string("alert"), |
cda3738a85bd
use ngx_str_t for error levels
Igor Sysoev <igor@sysoev.ru>
parents:
2737
diff
changeset
|
79 ngx_string("crit"), |
cda3738a85bd
use ngx_str_t for error levels
Igor Sysoev <igor@sysoev.ru>
parents:
2737
diff
changeset
|
80 ngx_string("error"), |
cda3738a85bd
use ngx_str_t for error levels
Igor Sysoev <igor@sysoev.ru>
parents:
2737
diff
changeset
|
81 ngx_string("warn"), |
2742
e138f820b5dc
style fix: remove trailing spaces introduced in the previous commit
Igor Sysoev <igor@sysoev.ru>
parents:
2741
diff
changeset
|
82 ngx_string("notice"), |
e138f820b5dc
style fix: remove trailing spaces introduced in the previous commit
Igor Sysoev <igor@sysoev.ru>
parents:
2741
diff
changeset
|
83 ngx_string("info"), |
2741
cda3738a85bd
use ngx_str_t for error levels
Igor Sysoev <igor@sysoev.ru>
parents:
2737
diff
changeset
|
84 ngx_string("debug") |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
85 }; |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
86 |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
87 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
|
88 "debug_core", "debug_alloc", "debug_mutex", "debug_event", |
6484
4b420f9c4c5d
Removed the prototype mysql module.
Ruslan Ermilov <ru@nginx.com>
parents:
6474
diff
changeset
|
89 "debug_http", "debug_mail", "debug_stream" |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
90 }; |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
91 |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
92 |
455 | 93 #if (NGX_HAVE_VARIADIC_MACROS) |
503 | 94 |
95 void | |
96 ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err, | |
97 const char *fmt, ...) | |
98 | |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
99 #else |
503 | 100 |
101 void | |
102 ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err, | |
103 const char *fmt, va_list args) | |
104 | |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
105 #endif |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
106 { |
455 | 107 #if (NGX_HAVE_VARIADIC_MACROS) |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
108 va_list args; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
109 #endif |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
110 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
|
111 ssize_t n; |
727177743c3c
Core: added disk_full_time checks to error log.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5771
diff
changeset
|
112 ngx_uint_t wrote_stderr, debug_connection; |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
113 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
|
114 |
461 | 115 last = errstr + NGX_MAX_ERROR_STR; |
116 | |
6000
93fee708f168
Log: use ngx_cpymem() in a couple of places, no functional changes.
Valentin Bartenev <vbart@nginx.com>
parents:
5962
diff
changeset
|
117 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
|
118 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
|
119 |
2764
d4a717592877
use ngx_vslprintf(), ngx_slprintf()
Igor Sysoev <igor@sysoev.ru>
parents:
2758
diff
changeset
|
120 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
|
121 |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
28
diff
changeset
|
122 /* pid#tid */ |
2764
d4a717592877
use ngx_vslprintf(), ngx_slprintf()
Igor Sysoev <igor@sysoev.ru>
parents:
2758
diff
changeset
|
123 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
|
124 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
|
125 |
483 | 126 if (log->connection) { |
2764
d4a717592877
use ngx_vslprintf(), ngx_slprintf()
Igor Sysoev <igor@sysoev.ru>
parents:
2758
diff
changeset
|
127 p = ngx_slprintf(p, last, "*%uA ", log->connection); |
483 | 128 } |
129 | |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
130 msg = p; |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
131 |
455 | 132 #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
|
133 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
134 va_start(args, fmt); |
2764
d4a717592877
use ngx_vslprintf(), ngx_slprintf()
Igor Sysoev <igor@sysoev.ru>
parents:
2758
diff
changeset
|
135 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
|
136 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
|
137 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
138 #else |
191
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
186
diff
changeset
|
139 |
2764
d4a717592877
use ngx_vslprintf(), ngx_slprintf()
Igor Sysoev <igor@sysoev.ru>
parents:
2758
diff
changeset
|
140 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
|
141 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
142 #endif |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
143 |
6
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
144 if (err) { |
2765 | 145 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
|
146 } |
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
147 |
36
c14d7232b11f
nginx-0.0.1-2002-12-23-09:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
28
diff
changeset
|
148 if (level != NGX_LOG_DEBUG && log->handler) { |
483 | 149 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
|
150 } |
6
669801705ab1
nginx-0.0.1-2002-08-26-19:18:19 import
Igor Sysoev <igor@sysoev.ru>
parents:
1
diff
changeset
|
151 |
571 | 152 if (p > last - NGX_LINEFEED_SIZE) { |
153 p = last - NGX_LINEFEED_SIZE; | |
461 | 154 } |
155 | |
571 | 156 ngx_linefeed(p); |
467 | 157 |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
158 wrote_stderr = 0; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
159 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
|
160 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
161 while (log) { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
162 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
163 if (log->log_level < level && !debug_connection) { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
164 break; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
165 } |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
166 |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
167 if (log->writer) { |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
168 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
|
169 goto next; |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
170 } |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
171 |
5962
727177743c3c
Core: added disk_full_time checks to error log.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5771
diff
changeset
|
172 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
|
173 |
727177743c3c
Core: added disk_full_time checks to error log.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5771
diff
changeset
|
174 /* |
727177743c3c
Core: added disk_full_time checks to error log.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5771
diff
changeset
|
175 * 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
|
176 * 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
|
177 * 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
|
178 */ |
727177743c3c
Core: added disk_full_time checks to error log.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5771
diff
changeset
|
179 |
727177743c3c
Core: added disk_full_time checks to error log.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5771
diff
changeset
|
180 goto next; |
727177743c3c
Core: added disk_full_time checks to error log.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5771
diff
changeset
|
181 } |
727177743c3c
Core: added disk_full_time checks to error log.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5771
diff
changeset
|
182 |
727177743c3c
Core: added disk_full_time checks to error log.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5771
diff
changeset
|
183 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
|
184 |
727177743c3c
Core: added disk_full_time checks to error log.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5771
diff
changeset
|
185 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
|
186 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
|
187 } |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
188 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
189 if (log->file->fd == ngx_stderr) { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
190 wrote_stderr = 1; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
191 } |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
192 |
5962
727177743c3c
Core: added disk_full_time checks to error log.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5771
diff
changeset
|
193 next: |
727177743c3c
Core: added disk_full_time checks to error log.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5771
diff
changeset
|
194 |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
195 log = log->next; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
196 } |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
197 |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
198 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
|
199 || level > NGX_LOG_WARN |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
200 || 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
|
201 { |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
202 return; |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
203 } |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
204 |
3822
75ffcfc700f3
remove semicolon, because it is already in "nginx: " prefix
Igor Sysoev <igor@sysoev.ru>
parents:
3799
diff
changeset
|
205 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
|
206 |
3822
75ffcfc700f3
remove semicolon, because it is already in "nginx: " prefix
Igor Sysoev <igor@sysoev.ru>
parents:
3799
diff
changeset
|
207 (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
|
208 |
2769
9d986c4e796f
introduce ngx_write_console() to support OEM code pages
Igor Sysoev <igor@sysoev.ru>
parents:
2765
diff
changeset
|
209 (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
|
210 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
211 |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
83
diff
changeset
|
212 |
455 | 213 #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
|
214 |
503 | 215 void ngx_cdecl |
216 ngx_log_error(ngx_uint_t level, ngx_log_t *log, ngx_err_t err, | |
217 const char *fmt, ...) | |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
218 { |
461 | 219 va_list args; |
0
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 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
|
222 va_start(args, fmt); |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
223 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
|
224 va_end(args); |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
225 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
226 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
227 |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
83
diff
changeset
|
228 |
503 | 229 void ngx_cdecl |
230 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
|
231 { |
461 | 232 va_list args; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
233 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
234 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
|
235 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
|
236 va_end(args); |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
237 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
238 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
239 #endif |
92
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
83
diff
changeset
|
240 |
19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
83
diff
changeset
|
241 |
2752
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
242 void ngx_cdecl |
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
243 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
|
244 { |
2752
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
245 u_char *p; |
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
246 va_list args; |
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
247 u_char errstr[NGX_MAX_CONF_ERRSTR]; |
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
248 |
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
249 va_start(args, fmt); |
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
250 p = ngx_vsnprintf(errstr, sizeof(errstr) - 1, fmt, args); |
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
251 va_end(args); |
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
252 |
2d82d3cfbfa0
change ngx_log_abort() interface
Igor Sysoev <igor@sysoev.ru>
parents:
2750
diff
changeset
|
253 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
|
254 "%*s", p - errstr, errstr); |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
639
diff
changeset
|
255 } |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
639
diff
changeset
|
256 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
639
diff
changeset
|
257 |
2722 | 258 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
|
259 ngx_log_stderr(ngx_err_t err, const char *fmt, ...) |
2722 | 260 { |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
261 u_char *p, *last; |
2722 | 262 va_list args; |
263 u_char errstr[NGX_MAX_ERROR_STR]; | |
264 | |
2764
d4a717592877
use ngx_vslprintf(), ngx_slprintf()
Igor Sysoev <igor@sysoev.ru>
parents:
2758
diff
changeset
|
265 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
|
266 |
6000
93fee708f168
Log: use ngx_cpymem() in a couple of places, no functional changes.
Valentin Bartenev <vbart@nginx.com>
parents:
5962
diff
changeset
|
267 p = ngx_cpymem(errstr, "nginx: ", 7); |
2764
d4a717592877
use ngx_vslprintf(), ngx_slprintf()
Igor Sysoev <igor@sysoev.ru>
parents:
2758
diff
changeset
|
268 |
2722 | 269 va_start(args, fmt); |
3799
188007bf58c3
add "nginx: " prefix when logging to the stderr
Igor Sysoev <igor@sysoev.ru>
parents:
3787
diff
changeset
|
270 p = ngx_vslprintf(p, last, fmt, args); |
2722 | 271 va_end(args); |
272 | |
2765 | 273 if (err) { |
274 p = ngx_log_errno(p, last, err); | |
2722 | 275 } |
276 | |
2765 | 277 if (p > last - NGX_LINEFEED_SIZE) { |
278 p = last - NGX_LINEFEED_SIZE; | |
2732 | 279 } |
280 | |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
281 ngx_linefeed(p); |
2732 | 282 |
2769
9d986c4e796f
introduce ngx_write_console() to support OEM code pages
Igor Sysoev <igor@sysoev.ru>
parents:
2765
diff
changeset
|
283 (void) ngx_write_console(ngx_stderr, errstr, p - errstr); |
2722 | 284 } |
285 | |
286 | |
2765 | 287 u_char * |
288 ngx_log_errno(u_char *buf, u_char *last, ngx_err_t err) | |
289 { | |
290 if (buf > last - 50) { | |
291 | |
292 /* leave a space for an error code */ | |
293 | |
294 buf = last - 50; | |
295 *buf++ = '.'; | |
296 *buf++ = '.'; | |
297 *buf++ = '.'; | |
298 } | |
299 | |
300 #if (NGX_WIN32) | |
301 buf = ngx_slprintf(buf, last, ((unsigned) err < 0x80000000) | |
302 ? " (%d: " : " (%Xd: ", err); | |
303 #else | |
304 buf = ngx_slprintf(buf, last, " (%d: ", err); | |
305 #endif | |
306 | |
3787
e294f37401c0
use copied strerror() messages and autoconfigured sys_nerr value
Igor Sysoev <igor@sysoev.ru>
parents:
3516
diff
changeset
|
307 buf = ngx_strerror(err, buf, last - buf); |
2765 | 308 |
309 if (buf < last) { | |
310 *buf++ = ')'; | |
311 } | |
312 | |
313 return buf; | |
314 } | |
315 | |
316 | |
503 | 317 ngx_log_t * |
2758 | 318 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
|
319 { |
2758 | 320 u_char *p, *name; |
321 size_t nlen, plen; | |
322 | |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
323 ngx_log.file = &ngx_log_file; |
461 | 324 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
|
325 |
2758 | 326 name = (u_char *) NGX_ERROR_LOG_PATH; |
327 | |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
328 /* |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
329 * 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
|
330 * 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
|
331 */ |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
332 |
2758 | 333 nlen = ngx_strlen(name); |
334 | |
335 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
|
336 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
|
337 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
|
338 } |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
339 |
2758 | 340 p = NULL; |
341 | |
342 #if (NGX_WIN32) | |
343 if (name[1] != ':') { | |
344 #else | |
345 if (name[0] != '/') { | |
346 #endif | |
347 | |
348 if (prefix) { | |
349 plen = ngx_strlen(prefix); | |
350 | |
2773
7a44b1932741
fix building by BCC if NGX_PREFIX is defined
Igor Sysoev <igor@sysoev.ru>
parents:
2769
diff
changeset
|
351 } else { |
2758 | 352 #ifdef NGX_PREFIX |
353 prefix = (u_char *) NGX_PREFIX; | |
354 plen = ngx_strlen(prefix); | |
2773
7a44b1932741
fix building by BCC if NGX_PREFIX is defined
Igor Sysoev <igor@sysoev.ru>
parents:
2769
diff
changeset
|
355 #else |
7a44b1932741
fix building by BCC if NGX_PREFIX is defined
Igor Sysoev <igor@sysoev.ru>
parents:
2769
diff
changeset
|
356 plen = 0; |
2758 | 357 #endif |
358 } | |
359 | |
360 if (plen) { | |
361 name = malloc(plen + nlen + 2); | |
362 if (name == NULL) { | |
363 return NULL; | |
364 } | |
365 | |
366 p = ngx_cpymem(name, prefix, plen); | |
367 | |
368 if (!ngx_path_separator(*(p - 1))) { | |
369 *p++ = '/'; | |
370 } | |
371 | |
372 ngx_cpystrn(p, (u_char *) NGX_ERROR_LOG_PATH, nlen + 1); | |
373 | |
374 p = name; | |
375 } | |
376 } | |
377 | |
378 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
|
379 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
|
380 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
|
381 |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
382 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
|
383 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
|
384 "[alert] could not open error log file: " |
2758 | 385 ngx_open_file_n " \"%s\" failed", name); |
461 | 386 #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
|
387 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
|
388 "could not open error log file: " |
2758 | 389 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
|
390 #endif |
100
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
391 |
2758 | 392 ngx_log_file.fd = ngx_stderr; |
393 } | |
394 | |
395 if (p) { | |
396 ngx_free(p); | |
461 | 397 } |
207
6e0fef527732
nginx-0.0.1-2003-12-05-20:07:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
398 |
448
241dc8092a33
nginx-0.1.0-2004-10-01-19:53:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
445
diff
changeset
|
399 return &ngx_log; |
241dc8092a33
nginx-0.1.0-2004-10-01-19:53:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
445
diff
changeset
|
400 } |
241dc8092a33
nginx-0.1.0-2004-10-01-19:53:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
445
diff
changeset
|
401 |
241dc8092a33
nginx-0.1.0-2004-10-01-19:53:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
445
diff
changeset
|
402 |
5260
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
403 ngx_int_t |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
404 ngx_log_open_default(ngx_cycle_t *cycle) |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
405 { |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
406 ngx_log_t *log; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
407 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
|
408 |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
409 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
|
410 return NGX_OK; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
411 } |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
412 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
413 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
|
414 /* 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
|
415 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
416 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
|
417 if (log == NULL) { |
5260
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
418 return NGX_ERROR; |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
419 } |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
420 |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
421 } else { |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
422 /* 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
|
423 log = &cycle->new_log; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
424 } |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
425 |
5771
c3b08217f2a2
Core: fixed default log initialization.
Vladimir Homutov <vl@nginx.com>
parents:
5702
diff
changeset
|
426 log->log_level = NGX_LOG_ERR; |
c3b08217f2a2
Core: fixed default log initialization.
Vladimir Homutov <vl@nginx.com>
parents:
5702
diff
changeset
|
427 |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
428 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
|
429 if (log->file == NULL) { |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
430 return NGX_ERROR; |
5260
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 |
5771
c3b08217f2a2
Core: fixed default log initialization.
Vladimir Homutov <vl@nginx.com>
parents:
5702
diff
changeset
|
433 if (log != &cycle->new_log) { |
c3b08217f2a2
Core: fixed default log initialization.
Vladimir Homutov <vl@nginx.com>
parents:
5702
diff
changeset
|
434 ngx_log_insert(&cycle->new_log, log); |
c3b08217f2a2
Core: fixed default log initialization.
Vladimir Homutov <vl@nginx.com>
parents:
5702
diff
changeset
|
435 } |
c3b08217f2a2
Core: fixed default log initialization.
Vladimir Homutov <vl@nginx.com>
parents:
5702
diff
changeset
|
436 |
5260
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
437 return NGX_OK; |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
438 } |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
439 |
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 ngx_int_t |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
442 ngx_log_redirect_stderr(ngx_cycle_t *cycle) |
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 ngx_fd_t fd; |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
445 |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
446 if (cycle->log_use_stderr) { |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
447 return NGX_OK; |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
448 } |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
449 |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
450 /* 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
|
451 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
|
452 |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
453 if (fd != ngx_stderr) { |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
454 if (ngx_set_stderr(fd) == NGX_FILE_ERROR) { |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
455 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
|
456 ngx_set_stderr_n " failed"); |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
457 |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
458 return NGX_ERROR; |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
459 } |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
460 } |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
461 |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
462 return NGX_OK; |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
463 } |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
464 |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
465 |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
466 ngx_log_t * |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
467 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
|
468 { |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
469 ngx_log_t *log; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
470 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
471 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
|
472 if (log->file != NULL) { |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
473 return log; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
474 } |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
475 } |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
476 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
477 return NULL; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
478 } |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
479 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
480 |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
481 static char * |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
482 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
|
483 { |
4012
bf452af6c1d2
Complain on invalid log levels.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3871
diff
changeset
|
484 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
|
485 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
|
486 |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
487 if (cf->args->nelts == 2) { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
488 log->log_level = NGX_LOG_ERR; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
489 return NGX_CONF_OK; |
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 |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
232
diff
changeset
|
492 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
|
493 |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
494 for (i = 2; i < cf->args->nelts; i++) { |
4012
bf452af6c1d2
Complain on invalid log levels.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3871
diff
changeset
|
495 found = 0; |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
496 |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
249
diff
changeset
|
497 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
|
498 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
|
499 |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
232
diff
changeset
|
500 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
|
501 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
|
502 "duplicate log level \"%V\"", |
cda3738a85bd
use ngx_str_t for error levels
Igor Sysoev <igor@sysoev.ru>
parents:
2737
diff
changeset
|
503 &value[i]); |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
504 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
|
505 } |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
506 |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
232
diff
changeset
|
507 log->log_level = n; |
4012
bf452af6c1d2
Complain on invalid log levels.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3871
diff
changeset
|
508 found = 1; |
bf452af6c1d2
Complain on invalid log levels.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3871
diff
changeset
|
509 break; |
207
6e0fef527732
nginx-0.0.1-2003-12-05-20:07:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
510 } |
6e0fef527732
nginx-0.0.1-2003-12-05-20:07:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
511 } |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
512 |
236
86e473b5641e
nginx-0.0.1-2004-01-22-09:47:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
235
diff
changeset
|
513 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
|
514 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
|
515 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
|
516 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
|
517 "invalid log level \"%V\"", |
cda3738a85bd
use ngx_str_t for error levels
Igor Sysoev <igor@sysoev.ru>
parents:
2737
diff
changeset
|
518 &value[i]); |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
519 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
|
520 } |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
521 |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
232
diff
changeset
|
522 log->log_level |= d; |
4012
bf452af6c1d2
Complain on invalid log levels.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3871
diff
changeset
|
523 found = 1; |
bf452af6c1d2
Complain on invalid log levels.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3871
diff
changeset
|
524 break; |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
525 } |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
526 } |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
527 |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
528 |
4012
bf452af6c1d2
Complain on invalid log levels.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3871
diff
changeset
|
529 if (!found) { |
207
6e0fef527732
nginx-0.0.1-2003-12-05-20:07:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
530 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
|
531 "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
|
532 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
|
533 } |
100
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
534 } |
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
535 |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
536 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
|
537 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
|
538 } |
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
249
diff
changeset
|
539 |
100
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
540 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
|
541 } |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
542 |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
543 |
503 | 544 static char * |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
545 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
|
546 { |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
547 ngx_log_t *dummy; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
548 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
549 dummy = &cf->cycle->new_log; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
550 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
551 return ngx_log_set_log(cf, &dummy); |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
552 } |
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 char * |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
556 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
|
557 { |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
558 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
|
559 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
|
560 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
|
561 |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
562 if (*head != NULL && (*head)->log_level == 0) { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
563 new_log = *head; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
564 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
565 } else { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
566 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
567 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
|
568 if (new_log == NULL) { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
569 return NGX_CONF_ERROR; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
570 } |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
571 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
572 if (*head == NULL) { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
573 *head = new_log; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
574 } |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
575 } |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
576 |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
577 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
|
578 |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
579 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
|
580 ngx_str_null(&name); |
5240
d8af1005e886
Core: fixed handling of "stderr" in error_log.
Vladimir Homutov <vl@nginx.com>
parents:
4412
diff
changeset
|
581 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
|
582 |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
583 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
|
584 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
|
585 return NGX_CONF_ERROR; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
586 } |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
587 |
6474 | 588 } else if (ngx_strncmp(value[1].data, "memory:", 7) == 0) { |
6033
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
589 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
590 #if (NGX_DEBUG) |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
591 size_t size, needed; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
592 ngx_pool_cleanup_t *cln; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
593 ngx_log_memory_buf_t *buf; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
594 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
595 value[1].len -= 7; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
596 value[1].data += 7; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
597 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
598 needed = sizeof("MEMLOG :" NGX_LINEFEED) |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
599 + cf->conf_file->file.name.len |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
600 + NGX_SIZE_T_LEN |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
601 + NGX_INT_T_LEN |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
602 + NGX_MAX_ERROR_STR; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
603 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
604 size = ngx_parse_size(&value[1]); |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
605 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
606 if (size == (size_t) NGX_ERROR || size < needed) { |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
607 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
608 "invalid buffer size \"%V\"", &value[1]); |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
609 return NGX_CONF_ERROR; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
610 } |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
611 |
6149
2c21bfe3da89
Core: properly initialized written bytes counter in memory log.
Valentin Bartenev <vbart@nginx.com>
parents:
6115
diff
changeset
|
612 buf = ngx_pcalloc(cf->pool, sizeof(ngx_log_memory_buf_t)); |
6033
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
613 if (buf == NULL) { |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
614 return NGX_CONF_ERROR; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
615 } |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
616 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
617 buf->start = ngx_pnalloc(cf->pool, size); |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
618 if (buf->start == NULL) { |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
619 return NGX_CONF_ERROR; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
620 } |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
621 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
622 buf->end = buf->start + size; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
623 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
624 buf->pos = ngx_slprintf(buf->start, buf->end, "MEMLOG %uz %V:%ui%N", |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
625 size, &cf->conf_file->file.name, |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
626 cf->conf_file->line); |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
627 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
628 ngx_memset(buf->pos, ' ', buf->end - buf->pos); |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
629 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
630 cln = ngx_pool_cleanup_add(cf->pool, 0); |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
631 if (cln == NULL) { |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
632 return NGX_CONF_ERROR; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
633 } |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
634 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
635 cln->data = new_log; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
636 cln->handler = ngx_log_memory_cleanup; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
637 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
638 new_log->writer = ngx_log_memory_writer; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
639 new_log->wdata = buf; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
640 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
641 #else |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
642 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
643 "nginx was built without debug support"); |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
644 return NGX_CONF_ERROR; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
645 #endif |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
646 |
6474 | 647 } else if (ngx_strncmp(value[1].data, "syslog:", 7) == 0) { |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
648 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
|
649 if (peer == NULL) { |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
650 return NGX_CONF_ERROR; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
651 } |
445
f26432a1935a
nginx-0.1.0-2004-09-30-10:38:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
652 |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
653 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
|
654 return NGX_CONF_ERROR; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
655 } |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
656 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
657 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
|
658 new_log->wdata = peer; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
659 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
660 } else { |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
661 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
|
662 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
|
663 return NGX_CONF_ERROR; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
664 } |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
665 } |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
666 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
667 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
|
668 return NGX_CONF_ERROR; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
669 } |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
670 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
671 if (*head != new_log) { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
672 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
|
673 } |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
674 |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
675 return NGX_CONF_OK; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
676 } |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
677 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
678 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
679 static void |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
680 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
|
681 { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
682 ngx_log_t tmp; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
683 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
684 if (new_log->log_level > log->log_level) { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
685 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
686 /* |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
687 * 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
|
688 * head and swap its contents with head |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
689 */ |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
690 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
691 tmp = *log; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
692 *log = *new_log; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
693 *new_log = tmp; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
694 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
695 log->next = new_log; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
696 return; |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
697 } |
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
698 |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
699 while (log->next) { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
700 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
|
701 new_log->next = log->next; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
702 log->next = new_log; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
703 return; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
704 } |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
705 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
706 log = log->next; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
707 } |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
708 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
709 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
|
710 } |
6033
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
711 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
712 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
713 #if (NGX_DEBUG) |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
714 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
715 static void |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
716 ngx_log_memory_writer(ngx_log_t *log, ngx_uint_t level, u_char *buf, |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
717 size_t len) |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
718 { |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
719 u_char *p; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
720 size_t avail, written; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
721 ngx_log_memory_buf_t *mem; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
722 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
723 mem = log->wdata; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
724 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
725 if (mem == NULL) { |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
726 return; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
727 } |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
728 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
729 written = ngx_atomic_fetch_add(&mem->written, len); |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
730 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
731 p = mem->pos + written % (mem->end - mem->pos); |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
732 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
733 avail = mem->end - p; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
734 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
735 if (avail >= len) { |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
736 ngx_memcpy(p, buf, len); |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
737 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
738 } else { |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
739 ngx_memcpy(p, buf, avail); |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
740 ngx_memcpy(mem->pos, buf + avail, len - avail); |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
741 } |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
742 } |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
743 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
744 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
745 static void |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
746 ngx_log_memory_cleanup(void *data) |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
747 { |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
748 ngx_log_t *log = data; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
749 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
750 ngx_log_debug0(NGX_LOG_DEBUG_CORE, log, 0, "destroy memory log buffer"); |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
751 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
752 log->wdata = NULL; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
753 } |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
754 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
755 #endif |