def test_access_logs_with_format_name(): config = ''' http { access_log /path/to/main.log main gzip=5 buffer=32k flush=1m; server { access_log /path/to/test.log 'te st'; } } ''' logs = dict(config_parser.get_access_logs(config)) assert len(logs) == 2 assert logs['/path/to/main.log'] == 'main' assert logs['/path/to/test.log'] == 'te st'
def test_access_logs_with_format_name(): config = """ http { access_log /path/to/main.log main gzip=5 buffer=32k flush=1m; server { access_log /path/to/test.log 'te st'; } } """ logs = dict(config_parser.get_access_logs(config)) assert len(logs) == 2 assert logs["/path/to/main.log"] == "main" assert logs["/path/to/test.log"] == "te st"
def test_get_access_logs_no_format(): config = ''' http { # ubuntu default access_log /var/log/nginx/access.log; # syslog is a valid access log, but we can't follow it access_log syslog:server=address combined; # commented # access_log commented; server { location / { # has parameter with default format access_log /path/to/log gzip=1; } } } ''' logs = dict(config_parser.get_access_logs(config)) assert len(logs) == 2 assert logs['/var/log/nginx/access.log'] == 'combined' assert logs['/path/to/log'] == 'combined'