# HG changeset patch # User Sergey Kandaurov # Date 1446112436 -10800 # Node ID abe795720deb0d378cac6203db2363a0dbfd3212 # Parent c35b071d4b47495eb3fd468f563c0d9ee1285060 Tests: added test for syslog nohostname parameter. diff --git a/syslog.t b/syslog.t --- a/syslog.t +++ b/syslog.t @@ -26,7 +26,7 @@ plan(skip_all => 'win32') if $^O eq 'MSW my $t = Test::Nginx->new()->has(qw/http limit_req/); -$t->plan(58)->write_file_expand('nginx.conf', <<'EOF'); +$t->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%% @@ -92,6 +92,10 @@ http { access_log syslog:server=127.0.0.1:8085 logf if=$arg_logme; } + location /nohostname { + access_log syslog:server=127.0.0.1:8080,nohostname; + } + location /debug { limit_req zone=one; error_log syslog:server=127.0.0.1:8080 debug; @@ -141,7 +145,7 @@ EOF $t->waitforfile($t->testdir . '/s_http.log'); $t->waitforfile($t->testdir . '/s_if.log'); -$t->run(); +$t->try_run('no syslog nohostname')->plan(59); ############################################################################### @@ -209,6 +213,14 @@ get_syslog('/a'); like($t->read_file('s_if.log'), qr/good:404.*work:404/s, 'syslog if success'); unlike($t->read_file('s_if.log'), qr/(if:|empty:|zero:)404/, 'syslog if fail'); +like(get_syslog('/nohostname'), + qr/^<(\d{1,3})> # PRI + ([A-Z][a-z]{2})\s # mon + ([ \d]\d)\s(\d{2}):(\d{2}):(\d{2})\s # date + (\w{1,32}):\s # tag + (.*)/x, # MSG + 'nohostname'); + ############################################################################### sub syslog_lines {