#! /bin/bash lnav_test="${top_builddir}/src/lnav-test" run_test env TZ=UTC ${lnav_test} -n \ -I ${test_dir} \ ${test_dir}/logfile_journald.json check_output "journald json log format is not working" <,2013-09-06 20:00:48.124,0,trace,0,,,,,, 2,,2013-09-06 20:00:49.124,1000,info,0,,,,,, 4,,2013-09-06 22:00:49.124,7200000,info,0,,,,,,steve@example.com 7,,2013-09-06 22:00:59.124,10000,debug5,0,,,,,, 9,,2013-09-06 22:00:59.124,0,debug4,0,,,,,, 11,,2013-09-06 22:00:59.124,0,debug3,0,,,,,, 13,,2013-09-06 22:00:59.124,0,debug2,0,,,,,, 15,,2013-09-06 22:00:59.124,0,debug,0,,,,,, 17,,2013-09-06 22:01:49.124,50000,stats,0,,,,,, 19,,2013-09-06 22:01:49.124,0,warning,0,,,,,, 21,,2013-09-06 22:01:49.124,0,error,0,,,,,, 23,,2013-09-06 22:01:49.124,0,critical,0,,,,,, 25,,2013-09-06 22:01:49.124,0,fatal,0,,,,"[""hi"", {""sub1"": true}]","{ ""field1"" : ""hi"", ""field2"": 2 }", EOF run_test ${lnav_test} -n \ -I ${test_dir} \ -c ';select * from test_log' \ -c ':write-json-to -' \ ${test_dir}/logfile_json.json check_output "json output not working" <,2013-09-06 20:00:49.124,0,info,0,,,,,com.exmaple.foo 1,,2013-09-06 22:00:49.124,7200000,info,0,,,,steve@example.com,com.exmaple.foo 3,,2013-09-06 22:01:49.124,60000,error,0,,,,,com.exmaple.foo EOF run_test ${lnav_test} -n \ -I ${test_dir} \ -c ":goto 4" \ -c ":pipe-line-to sed -e 's/2013//g'" \ -c ":switch-to-view text" \ ${test_dir}/logfile_json.json check_output "pipe-line-to is not working" <,2013-09-06 20:00:48.124,0,trace,0,,,,, 2,,2013-09-06 20:00:49.124,1000,info,0,,,,, 4,,2013-09-06 22:00:49.124,7200000,info,0,,,,steve@example.com, 7,,2013-09-06 22:00:59.124,10000,debug5,0,,,,, 9,,2013-09-06 22:00:59.124,0,debug4,0,,,,, 11,,2013-09-06 22:00:59.124,0,debug3,0,,,,, 13,,2013-09-06 22:00:59.124,0,debug2,0,,,,, 15,,2013-09-06 22:00:59.124,0,debug,0,,,,, 17,,2013-09-06 22:01:49.124,50000,stats,0,,,,, 19,,2013-09-06 22:01:49.124,0,warning,0,,,,, 21,,2013-09-06 22:01:49.124,0,error,0,,,,, 23,,2013-09-06 22:01:49.124,0,critical,0,,,,, 25,,2013-09-06 22:01:49.124,0,fatal,0,,,,,line:1 EOF run_test ${lnav_test} -n \ -I ${test_dir} \ -c ":goto 4" \ -c ":pipe-line-to sed -e 's/2013//g'" \ -c ":switch-to-view text" \ ${test_dir}/logfile_nested_json.json check_output "pipe-line-to is not working" <,2017-03-24 20:06:26.240,0,info,0,,,,1.1.1.1,GET,/example/uri/5,166,200,,, 1,,2017-03-24 20:12:47.764,381524,critical,0,,,,1.1.1.1,GET,/example/uri/5,166,500,,, 2,,2017-03-24 20:15:31.694,163930,warning,0,,,,1.1.1.1,GET,/example/uri/5,166,400,"{""foo"": ""bar""}","{""foo"": ""bar""}","{""foo"": ""bar""}" EOF run_test ${lnav_test} -n \ -d /tmp/lnav.err \ -I ${test_dir} \ ${test_dir}/logfile_invalid_json.json check_output "json log format is not working" <