Mercurial > hg > nginx-quic
annotate src/core/ngx_log.c @ 8519:5f765427c17a
Fixed SSL logging with lingering close.
Recent fixes to SSL shutdown with lingering close (554c6ae25ffc, 1.19.5)
broke logging of SSL variables. To make sure logging of SSL variables
works properly, avoid freeing c->ssl when doing an SSL shutdown before
lingering close.
Reported by Reinis Rozitis
(http://mailman.nginx.org/pipermail/nginx/2021-May/060670.html).
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Tue, 01 Jun 2021 17:37:51 +0300 |
parents | f18db38a9826 |
children |
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 * |
8226
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
6484
diff
changeset
|
318 ngx_log_init(u_char *prefix, u_char *error_log) |
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 |
8226
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
6484
diff
changeset
|
326 if (error_log == NULL) { |
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
6484
diff
changeset
|
327 error_log = (u_char *) NGX_ERROR_LOG_PATH; |
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
6484
diff
changeset
|
328 } |
2758 | 329 |
8226
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
6484
diff
changeset
|
330 name = error_log; |
2758 | 331 nlen = ngx_strlen(name); |
332 | |
333 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
|
334 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
|
335 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
|
336 } |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
337 |
2758 | 338 p = NULL; |
339 | |
340 #if (NGX_WIN32) | |
341 if (name[1] != ':') { | |
342 #else | |
343 if (name[0] != '/') { | |
344 #endif | |
345 | |
346 if (prefix) { | |
347 plen = ngx_strlen(prefix); | |
348 | |
2773
7a44b1932741
fix building by BCC if NGX_PREFIX is defined
Igor Sysoev <igor@sysoev.ru>
parents:
2769
diff
changeset
|
349 } else { |
2758 | 350 #ifdef NGX_PREFIX |
351 prefix = (u_char *) NGX_PREFIX; | |
352 plen = ngx_strlen(prefix); | |
2773
7a44b1932741
fix building by BCC if NGX_PREFIX is defined
Igor Sysoev <igor@sysoev.ru>
parents:
2769
diff
changeset
|
353 #else |
7a44b1932741
fix building by BCC if NGX_PREFIX is defined
Igor Sysoev <igor@sysoev.ru>
parents:
2769
diff
changeset
|
354 plen = 0; |
2758 | 355 #endif |
356 } | |
357 | |
358 if (plen) { | |
359 name = malloc(plen + nlen + 2); | |
360 if (name == NULL) { | |
361 return NULL; | |
362 } | |
363 | |
364 p = ngx_cpymem(name, prefix, plen); | |
365 | |
366 if (!ngx_path_separator(*(p - 1))) { | |
367 *p++ = '/'; | |
368 } | |
369 | |
8226
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
6484
diff
changeset
|
370 ngx_cpystrn(p, error_log, nlen + 1); |
2758 | 371 |
372 p = name; | |
373 } | |
374 } | |
375 | |
376 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
|
377 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
|
378 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
|
379 |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2742
diff
changeset
|
380 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
|
381 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
|
382 "[alert] could not open error log file: " |
2758 | 383 ngx_open_file_n " \"%s\" failed", name); |
461 | 384 #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
|
385 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
|
386 "could not open error log file: " |
2758 | 387 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
|
388 #endif |
100
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
389 |
2758 | 390 ngx_log_file.fd = ngx_stderr; |
391 } | |
392 | |
393 if (p) { | |
394 ngx_free(p); | |
461 | 395 } |
207
6e0fef527732
nginx-0.0.1-2003-12-05-20:07:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
396 |
448
241dc8092a33
nginx-0.1.0-2004-10-01-19:53:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
445
diff
changeset
|
397 return &ngx_log; |
241dc8092a33
nginx-0.1.0-2004-10-01-19:53:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
445
diff
changeset
|
398 } |
241dc8092a33
nginx-0.1.0-2004-10-01-19:53:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
445
diff
changeset
|
399 |
241dc8092a33
nginx-0.1.0-2004-10-01-19:53:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
445
diff
changeset
|
400 |
5260
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
401 ngx_int_t |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
402 ngx_log_open_default(ngx_cycle_t *cycle) |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
403 { |
8226
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
6484
diff
changeset
|
404 ngx_log_t *log; |
5260
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 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
|
407 return NGX_OK; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
408 } |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
409 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
410 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
|
411 /* 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
|
412 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
413 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
|
414 if (log == NULL) { |
5260
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
415 return NGX_ERROR; |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
416 } |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
417 |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
418 } else { |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
419 /* 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
|
420 log = &cycle->new_log; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
421 } |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
422 |
5771
c3b08217f2a2
Core: fixed default log initialization.
Vladimir Homutov <vl@nginx.com>
parents:
5702
diff
changeset
|
423 log->log_level = NGX_LOG_ERR; |
c3b08217f2a2
Core: fixed default log initialization.
Vladimir Homutov <vl@nginx.com>
parents:
5702
diff
changeset
|
424 |
8226
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
6484
diff
changeset
|
425 log->file = ngx_conf_open_file(cycle, &cycle->error_log); |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
426 if (log->file == NULL) { |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
427 return NGX_ERROR; |
5260
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
428 } |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
429 |
5771
c3b08217f2a2
Core: fixed default log initialization.
Vladimir Homutov <vl@nginx.com>
parents:
5702
diff
changeset
|
430 if (log != &cycle->new_log) { |
c3b08217f2a2
Core: fixed default log initialization.
Vladimir Homutov <vl@nginx.com>
parents:
5702
diff
changeset
|
431 ngx_log_insert(&cycle->new_log, log); |
c3b08217f2a2
Core: fixed default log initialization.
Vladimir Homutov <vl@nginx.com>
parents:
5702
diff
changeset
|
432 } |
c3b08217f2a2
Core: fixed default log initialization.
Vladimir Homutov <vl@nginx.com>
parents:
5702
diff
changeset
|
433 |
5260
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
434 return NGX_OK; |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
435 } |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
436 |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
437 |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
438 ngx_int_t |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
439 ngx_log_redirect_stderr(ngx_cycle_t *cycle) |
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_fd_t fd; |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
442 |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
443 if (cycle->log_use_stderr) { |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
444 return NGX_OK; |
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 |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
447 /* 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
|
448 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
|
449 |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
450 if (fd != ngx_stderr) { |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
451 if (ngx_set_stderr(fd) == NGX_FILE_ERROR) { |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
452 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
|
453 ngx_set_stderr_n " failed"); |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
454 |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
455 return NGX_ERROR; |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
456 } |
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 |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5254
diff
changeset
|
459 return NGX_OK; |
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 |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
463 ngx_log_t * |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
464 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
|
465 { |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
466 ngx_log_t *log; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
467 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
468 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
|
469 if (log->file != NULL) { |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
470 return log; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
471 } |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
472 } |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
473 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
474 return NULL; |
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 |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
478 static char * |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
479 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
|
480 { |
4012
bf452af6c1d2
Complain on invalid log levels.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3871
diff
changeset
|
481 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
|
482 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
|
483 |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
484 if (cf->args->nelts == 2) { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
485 log->log_level = NGX_LOG_ERR; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
486 return NGX_CONF_OK; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
487 } |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
488 |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
232
diff
changeset
|
489 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
|
490 |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
491 for (i = 2; i < cf->args->nelts; i++) { |
4012
bf452af6c1d2
Complain on invalid log levels.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3871
diff
changeset
|
492 found = 0; |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
493 |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
249
diff
changeset
|
494 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
|
495 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
|
496 |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
232
diff
changeset
|
497 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
|
498 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
|
499 "duplicate log level \"%V\"", |
cda3738a85bd
use ngx_str_t for error levels
Igor Sysoev <igor@sysoev.ru>
parents:
2737
diff
changeset
|
500 &value[i]); |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
501 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
|
502 } |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
503 |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
232
diff
changeset
|
504 log->log_level = n; |
4012
bf452af6c1d2
Complain on invalid log levels.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3871
diff
changeset
|
505 found = 1; |
bf452af6c1d2
Complain on invalid log levels.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3871
diff
changeset
|
506 break; |
207
6e0fef527732
nginx-0.0.1-2003-12-05-20:07:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
507 } |
6e0fef527732
nginx-0.0.1-2003-12-05-20:07:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
508 } |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
509 |
236
86e473b5641e
nginx-0.0.1-2004-01-22-09:47:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
235
diff
changeset
|
510 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
|
511 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
|
512 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
|
513 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
2741
cda3738a85bd
use ngx_str_t for error levels
Igor Sysoev <igor@sysoev.ru>
parents:
2737
diff
changeset
|
514 "invalid log level \"%V\"", |
cda3738a85bd
use ngx_str_t for error levels
Igor Sysoev <igor@sysoev.ru>
parents:
2737
diff
changeset
|
515 &value[i]); |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
516 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
|
517 } |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
518 |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
232
diff
changeset
|
519 log->log_level |= d; |
4012
bf452af6c1d2
Complain on invalid log levels.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3871
diff
changeset
|
520 found = 1; |
bf452af6c1d2
Complain on invalid log levels.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3871
diff
changeset
|
521 break; |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
522 } |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
523 } |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
524 |
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
525 |
4012
bf452af6c1d2
Complain on invalid log levels.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3871
diff
changeset
|
526 if (!found) { |
207
6e0fef527732
nginx-0.0.1-2003-12-05-20:07:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
527 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
|
528 "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
|
529 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
|
530 } |
100
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
531 } |
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
532 |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
533 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
|
534 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
|
535 } |
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
249
diff
changeset
|
536 |
100
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
93
diff
changeset
|
537 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
|
538 } |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
539 |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
540 |
503 | 541 static char * |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
542 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
|
543 { |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
544 ngx_log_t *dummy; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
545 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
546 dummy = &cf->cycle->new_log; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
547 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
548 return ngx_log_set_log(cf, &dummy); |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
549 } |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
550 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
551 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
552 char * |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
553 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
|
554 { |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
555 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
|
556 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
|
557 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
|
558 |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
559 if (*head != NULL && (*head)->log_level == 0) { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
560 new_log = *head; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
561 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
562 } else { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
563 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
564 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
|
565 if (new_log == NULL) { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
566 return NGX_CONF_ERROR; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
567 } |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
568 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
569 if (*head == NULL) { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
570 *head = new_log; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
571 } |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
572 } |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
573 |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
574 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
|
575 |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
576 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
|
577 ngx_str_null(&name); |
5240
d8af1005e886
Core: fixed handling of "stderr" in error_log.
Vladimir Homutov <vl@nginx.com>
parents:
4412
diff
changeset
|
578 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
|
579 |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
580 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
|
581 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
|
582 return NGX_CONF_ERROR; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
583 } |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
584 |
6474 | 585 } 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
|
586 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
587 #if (NGX_DEBUG) |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
588 size_t size, needed; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
589 ngx_pool_cleanup_t *cln; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
590 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
|
591 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
592 value[1].len -= 7; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
593 value[1].data += 7; |
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 needed = sizeof("MEMLOG :" NGX_LINEFEED) |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
596 + 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
|
597 + NGX_SIZE_T_LEN |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
598 + NGX_INT_T_LEN |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
599 + NGX_MAX_ERROR_STR; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
600 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
601 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
|
602 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
603 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
|
604 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
|
605 "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
|
606 return NGX_CONF_ERROR; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
607 } |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
608 |
6149
2c21bfe3da89
Core: properly initialized written bytes counter in memory log.
Valentin Bartenev <vbart@nginx.com>
parents:
6115
diff
changeset
|
609 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
|
610 if (buf == NULL) { |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
611 return NGX_CONF_ERROR; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
612 } |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
613 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
614 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
|
615 if (buf->start == NULL) { |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
616 return NGX_CONF_ERROR; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
617 } |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
618 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
619 buf->end = buf->start + size; |
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 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
|
622 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
|
623 cf->conf_file->line); |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
624 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
625 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
|
626 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
627 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
|
628 if (cln == NULL) { |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
629 return NGX_CONF_ERROR; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
630 } |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
631 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
632 cln->data = new_log; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
633 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
|
634 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
635 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
|
636 new_log->wdata = buf; |
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 #else |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
639 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
|
640 "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
|
641 return NGX_CONF_ERROR; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
642 #endif |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
643 |
6474 | 644 } 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
|
645 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
|
646 if (peer == NULL) { |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
647 return NGX_CONF_ERROR; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
648 } |
445
f26432a1935a
nginx-0.1.0-2004-09-30-10:38:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
649 |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
650 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
|
651 return NGX_CONF_ERROR; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
652 } |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
653 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
654 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
|
655 new_log->wdata = peer; |
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 } else { |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
658 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
|
659 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
|
660 return NGX_CONF_ERROR; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5260
diff
changeset
|
661 } |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
662 } |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
663 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
664 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
|
665 return NGX_CONF_ERROR; |
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 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
668 if (*head != new_log) { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
669 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
|
670 } |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
671 |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
672 return NGX_CONF_OK; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
673 } |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
674 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
675 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
676 static void |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
677 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
|
678 { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
679 ngx_log_t tmp; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
680 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
681 if (new_log->log_level > log->log_level) { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
682 |
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 * 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
|
685 * head and swap its contents with head |
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 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
688 tmp = *log; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
689 *log = *new_log; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
690 *new_log = tmp; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
691 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
692 log->next = new_log; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
693 return; |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
694 } |
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2773
diff
changeset
|
695 |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
696 while (log->next) { |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
697 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
|
698 new_log->next = log->next; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
699 log->next = new_log; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
700 return; |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
701 } |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
702 |
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
703 log = log->next; |
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->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
|
707 } |
6033
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
708 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
709 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
710 #if (NGX_DEBUG) |
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 static void |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
713 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
|
714 size_t len) |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
715 { |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
716 u_char *p; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
717 size_t avail, written; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
718 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
|
719 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
720 mem = log->wdata; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
721 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
722 if (mem == NULL) { |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
723 return; |
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 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
726 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
|
727 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
728 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
|
729 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
730 avail = mem->end - p; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
731 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
732 if (avail >= len) { |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
733 ngx_memcpy(p, buf, len); |
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 } else { |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
736 ngx_memcpy(p, buf, avail); |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
737 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
|
738 } |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
739 } |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
740 |
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 static void |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
743 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
|
744 { |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
745 ngx_log_t *log = data; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
746 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
747 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
|
748 |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
749 log->wdata = NULL; |
8e66a83d16ae
Core: added cyclic memory buffer support for error_log.
Valentin Bartenev <vbart@nginx.com>
parents:
6000
diff
changeset
|
750 } |
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 #endif |