#! /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,,,,, 1,,2013-09-06 20:00:49.124,1000,info,0,,,,, 2,,2013-09-06 22:00:49.124,7200000,info,0,,,,,steve@example.com 4,,2013-09-06 22:00:59.124,10000,debug5,0,,,,, 5,,2013-09-06 22:00:59.124,0,debug4,0,,,,, 6,,2013-09-06 22:00:59.124,0,debug3,0,,,,, 7,,2013-09-06 22:00:59.124,0,debug2,0,,,,, 8,,2013-09-06 22:00:59.124,0,debug,0,,,,, 9,,2013-09-06 22:01:49.124,50000,stats,0,,,,, 10,,2013-09-06 22:01:49.124,0,warning,0,,,,, 11,,2013-09-06 22:01:49.124,0,error,0,,,,, 12,,2013-09-06 22:01:49.124,0,critical,0,,,,, 13,,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,,,com.exmaple.foo,steve@example.com 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 2" \ -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,,, 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,166,/example/uri/5,200 1,,2017-03-24 20:12:47.764,381524,critical,0,,,1.1.1.1,,,,GET,166,/example/uri/5,500 2,,2017-03-24 20:15:31.694,163930,warning,0,,,1.1.1.1,"{""foo"": ""bar""}","{""foo"": ""bar""}","{""foo"": ""bar""}",GET,166,/example/uri/5,400 EOF