Mercurial > hg > nginx
comparison src/core/ngx_syslog.c @ 6286:a6a2016b8e31
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).
author | Vladimir Homutov <vl@nginx.com> |
---|---|
date | Mon, 26 Oct 2015 19:06:42 +0300 |
parents | 68f64bc17fa4 |
children | 2cd019520210 |
comparison
equal
deleted
inserted
replaced
6285:1f26bf65b1bc | 6286:a6a2016b8e31 |
---|---|
192 } | 192 } |
193 | 193 |
194 peer->tag.data = p + 4; | 194 peer->tag.data = p + 4; |
195 peer->tag.len = len - 4; | 195 peer->tag.len = len - 4; |
196 | 196 |
197 } else if (len == 10 && ngx_strncmp(p, "nohostname", 10) == 0) { | |
198 peer->nohostname = 1; | |
199 | |
197 } else { | 200 } else { |
198 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | 201 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
199 "unknown syslog parameter \"%s\"", p); | 202 "unknown syslog parameter \"%s\"", p); |
200 return NGX_CONF_ERROR; | 203 return NGX_CONF_ERROR; |
201 } | 204 } |
218 { | 221 { |
219 ngx_uint_t pri; | 222 ngx_uint_t pri; |
220 | 223 |
221 pri = peer->facility * 8 + peer->severity; | 224 pri = peer->facility * 8 + peer->severity; |
222 | 225 |
226 if (peer->nohostname) { | |
227 return ngx_sprintf(buf, "<%ui>%V %V: ", pri, &ngx_cached_syslog_time, | |
228 &peer->tag); | |
229 } | |
230 | |
223 return ngx_sprintf(buf, "<%ui>%V %V %V: ", pri, &ngx_cached_syslog_time, | 231 return ngx_sprintf(buf, "<%ui>%V %V %V: ", pri, &ngx_cached_syslog_time, |
224 &ngx_cycle->hostname, &peer->tag); | 232 &ngx_cycle->hostname, &peer->tag); |
225 } | 233 } |
226 | 234 |
227 | 235 |