changeset 771:abe795720deb

Tests: added test for syslog nohostname parameter.
author Sergey Kandaurov <pluknet@nginx.com>
date Thu, 29 Oct 2015 12:53:56 +0300
parents c35b071d4b47
children cab9f60e561e
files syslog.t
diffstat 1 files changed, 14 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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 {