Welcome! Log In Create A New Profile

Advanced

[nginx] Syslog: added "nohostname" option.

Vladimir Homutov
October 29, 2015 05:18AM
details: http://hg.nginx.org/nginx/rev/a6a2016b8e31
branches:
changeset: 6286:a6a2016b8e31
user: Vladimir Homutov <vl@nginx.com>
date: Mon Oct 26 19:06:42 2015 +0300
description:
Syslog: added "nohostname" option.

The option disables sending hostname in the syslog message header. This is
useful with syslog daemons that do not expect it (tickets #677 and #783).

diffstat:

src/core/ngx_syslog.c | 8 ++++++++
src/core/ngx_syslog.h | 3 ++-
2 files changed, 10 insertions(+), 1 deletions(-)

diffs (38 lines):

diff -r 1f26bf65b1bc -r a6a2016b8e31 src/core/ngx_syslog.c
--- a/src/core/ngx_syslog.c Tue Oct 27 23:16:35 2015 +0300
+++ b/src/core/ngx_syslog.c Mon Oct 26 19:06:42 2015 +0300
@@ -194,6 +194,9 @@ ngx_syslog_parse_args(ngx_conf_t *cf, ng
peer->tag.data = p + 4;
peer->tag.len = len - 4;

+ } else if (len == 10 && ngx_strncmp(p, "nohostname", 10) == 0) {
+ peer->nohostname = 1;
+
} else {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"unknown syslog parameter \"%s\"", p);
@@ -220,6 +223,11 @@ ngx_syslog_add_header(ngx_syslog_peer_t

pri = peer->facility * 8 + peer->severity;

+ if (peer->nohostname) {
+ return ngx_sprintf(buf, "<%ui>%V %V: ", pri, &ngx_cached_syslog_time,
+ &peer->tag);
+ }
+
return ngx_sprintf(buf, "<%ui>%V %V %V: ", pri, &ngx_cached_syslog_time,
&ngx_cycle->hostname, &peer->tag);
}
diff -r 1f26bf65b1bc -r a6a2016b8e31 src/core/ngx_syslog.h
--- a/src/core/ngx_syslog.h Tue Oct 27 23:16:35 2015 +0300
+++ b/src/core/ngx_syslog.h Mon Oct 26 19:06:42 2015 +0300
@@ -16,7 +16,8 @@ typedef struct {

ngx_addr_t server;
ngx_connection_t conn;
- ngx_uint_t busy; /* unsigned busy:1; */
+ unsigned busy:1;
+ unsigned nohostname:1;
} ngx_syslog_peer_t;



_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] Syslog: added "nohostname" option.

Vladimir Homutov 837 October 29, 2015 05:18AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 286
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready