Mercurial > hg > nginx
comparison src/stream/ngx_stream_log_module.c @ 9224:c7c8354f99fa
Syslog: fixed duplicate errors with access logging to syslog.
The ngx_syslog_send() function logs errors itself, so there is no need
to additionally log errors in the caller, notably access log modules in
http and stream.
To ensure that incomplete and blocked writes are also logged, appropriate
logging added to ngx_syslog_send().
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Fri, 01 Mar 2024 05:42:09 +0300 |
parents | 1ab290cf5267 |
children |
comparison
equal
deleted
inserted
replaced
9223:697f452bc033 | 9224:c7c8354f99fa |
---|---|
199 | 199 |
200 static ngx_int_t | 200 static ngx_int_t |
201 ngx_stream_log_handler(ngx_stream_session_t *s) | 201 ngx_stream_log_handler(ngx_stream_session_t *s) |
202 { | 202 { |
203 u_char *line, *p; | 203 u_char *line, *p; |
204 size_t len, size; | 204 size_t len; |
205 ssize_t n; | |
206 ngx_str_t val; | 205 ngx_str_t val; |
207 ngx_uint_t i, l; | 206 ngx_uint_t i, l; |
208 ngx_stream_log_t *log; | 207 ngx_stream_log_t *log; |
209 ngx_stream_log_op_t *op; | 208 ngx_stream_log_op_t *op; |
210 ngx_stream_log_buf_t *buffer; | 209 ngx_stream_log_buf_t *buffer; |
322 p = op[i].run(s, p, &op[i]); | 321 p = op[i].run(s, p, &op[i]); |
323 } | 322 } |
324 | 323 |
325 if (log[l].syslog_peer) { | 324 if (log[l].syslog_peer) { |
326 | 325 |
327 size = p - line; | 326 (void) ngx_syslog_send(log[l].syslog_peer, line, p - line); |
328 | |
329 n = ngx_syslog_send(log[l].syslog_peer, line, size); | |
330 | |
331 if (n < 0) { | |
332 ngx_log_error(NGX_LOG_WARN, s->connection->log, 0, | |
333 "send() to syslog failed"); | |
334 | |
335 } else if ((size_t) n != size) { | |
336 ngx_log_error(NGX_LOG_WARN, s->connection->log, 0, | |
337 "send() to syslog has written only %z of %uz", | |
338 n, size); | |
339 } | |
340 | 327 |
341 continue; | 328 continue; |
342 } | 329 } |
343 | 330 |
344 ngx_linefeed(p); | 331 ngx_linefeed(p); |