[nginx] Stream: additional logging for UDP.

Vladimir Homutov vl at nginx.com
Thu Mar 24 05:57:06 UTC 2016


details:   http://hg.nginx.org/nginx/rev/a01e315b3a78
branches:  
changeset: 6461:a01e315b3a78
user:      Vladimir Homutov <vl at nginx.com>
date:      Fri Mar 18 19:53:22 2016 +0300
description:
Stream: additional logging for UDP.

diffstat:

 src/stream/ngx_stream_handler.c      |  8 +++++---
 src/stream/ngx_stream_proxy_module.c |  7 +++++--
 2 files changed, 10 insertions(+), 5 deletions(-)

diffs (51 lines):

diff -r 034329824dd3 -r a01e315b3a78 src/stream/ngx_stream_handler.c
--- a/src/stream/ngx_stream_handler.c	Wed Mar 23 18:34:05 2016 +0300
+++ b/src/stream/ngx_stream_handler.c	Fri Mar 18 19:53:22 2016 +0300
@@ -137,8 +137,9 @@ ngx_stream_init_connection(ngx_connectio
 
     len = ngx_sock_ntop(c->sockaddr, c->socklen, text, NGX_SOCKADDR_STRLEN, 1);
 
-    ngx_log_error(NGX_LOG_INFO, c->log, 0, "*%uA client %*s connected to %V",
-                  c->number, len, text, &addr_conf->addr_text);
+    ngx_log_error(NGX_LOG_INFO, c->log, 0, "*%uA %sclient %*s connected to %V",
+                  c->number, c->type == SOCK_DGRAM ? "udp " : "",
+                  len, text, &addr_conf->addr_text);
 
     c->log->connection = c->number;
     c->log->handler = ngx_stream_log_error;
@@ -328,7 +329,8 @@ ngx_stream_log_error(ngx_log_t *log, u_c
 
     s = log->data;
 
-    p = ngx_snprintf(buf, len, ", client: %V, server: %V",
+    p = ngx_snprintf(buf, len, ", %sclient: %V, server: %V",
+                     s->connection->type == SOCK_DGRAM ? "udp " : "",
                      &s->connection->addr_text,
                      &s->connection->listening->addr_text);
     len -= p - buf;
diff -r 034329824dd3 -r a01e315b3a78 src/stream/ngx_stream_proxy_module.c
--- a/src/stream/ngx_stream_proxy_module.c	Wed Mar 23 18:34:05 2016 +0300
+++ b/src/stream/ngx_stream_proxy_module.c	Fri Mar 18 19:53:22 2016 +0300
@@ -552,7 +552,9 @@ ngx_stream_proxy_init_upstream(ngx_strea
             handler = c->log->handler;
             c->log->handler = NULL;
 
-            ngx_log_error(NGX_LOG_INFO, c->log, 0, "proxy %V connected to %V",
+            ngx_log_error(NGX_LOG_INFO, c->log, 0,
+                          "%sproxy %V connected to %V",
+                          pc->type == SOCK_DGRAM ? "udp " : "",
                           &str, u->peer.name);
 
             c->log->handler = handler;
@@ -1222,9 +1224,10 @@ ngx_stream_proxy_process(ngx_stream_sess
         c->log->handler = NULL;
 
         ngx_log_error(NGX_LOG_INFO, c->log, 0,
-                      "%s disconnected"
+                      "%s%s disconnected"
                       ", bytes from/to client:%O/%O"
                       ", bytes from/to upstream:%O/%O",
+                      src->type == SOCK_DGRAM ? "udp " : "",
                       from_upstream ? "upstream" : "client",
                       s->received, c->sent, u->received, pc ? pc->sent : 0);
 



More information about the nginx-devel mailing list