#! /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 log_raw_text from test_log' \ -c ':write-raw-to -' \ ${test_dir}/logfile_json.json check_output "log levels not working" < ${test_dir}logfile_json.json run_test ${lnav_test} -n \ -I ${test_dir} \ -c ':goto 0' \ -c ':mark' \ -c ':goto 1' \ -c ':mark' \ -c ':goto 2' \ -c ':mark' \ -c ':write-raw-to -' \ ${test_dir}/log.clog check_output "write-raw-to with json is not working" <<'EOF' {"@timestamp":"2016-08-03T12:06:31.009-0500","@version":1,"message":";Exception initializing page context;","logger_name":"org.apache.jasper.runtime.JspFactoryImpl","thread_name":"http-bio-0.0.0.0-8081-exec-198","level":"ERROR","level_value":40000,"stack_trace":"java.lang.NoClassDefFoundError: javax/el/StaticFieldELResolver\n\tat org.apache.jasper.runtime.JspFactoryImpl.internalGetPageContext(JspFactoryImpl.java:172)\n\tat org.apache.jasper.runtime.JspFactoryImpl.getPageContext(JspFactoryImpl.java:123)\n\tat org.apache.jsp.errors._404_002dnot_002dfound_jsp._jspService(_404_002dnot_002dfound_jsp.java:38)\n\tat org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111)\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:731)\n\tat org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:411)\n\tat org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:473)\n\tat org.apache.jasper.servlet.JspServlet.service(JspServlet.java:377)\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:731)\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)\n\tat collective.config.startup.DamFilter.doFilter(DamFilter.java:270)\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)\n\tat org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:748)\n\tat org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:488)\n\tat org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:411)\n\tat org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:338)\n\tat org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:476)\n\tat org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:345)\n\tat org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:210)\n\tat org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)\n\tat org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)\n\tat org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:957)\n\tat org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:683)\n\tat org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)\n\tat org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)\n\tat org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620)\n\tat org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)\n\tat org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)\n\tat java.lang.Thread.run(Thread.java:744)\nCaused by: java.lang.ClassNotFoundException: javax.el.StaticFieldELResolver\n\tat org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)\n\tat org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)\n\t... 33 common frames omitted\n","customer":"foobaz"} 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" <