diff options
Diffstat (limited to 'test/formats')
-rw-r--r-- | test/formats/collision/format.json | 48 | ||||
-rw-r--r-- | test/formats/customlevel/format.json | 25 | ||||
-rw-r--r-- | test/formats/jsontest-subsec/format.json | 27 | ||||
-rw-r--r-- | test/formats/jsontest/format.json | 36 | ||||
-rw-r--r-- | test/formats/jsontest/lnav-logstash.json | 47 | ||||
-rw-r--r-- | test/formats/jsontest/rewrite-user.lnav | 2 | ||||
-rw-r--r-- | test/formats/jsontest2/format.json | 49 | ||||
-rw-r--r-- | test/formats/jsontest3/format.json | 75 | ||||
-rw-r--r-- | test/formats/nestedjson/format.json | 32 | ||||
-rw-r--r-- | test/formats/scripts/multiline-echo.lnav | 3 | ||||
-rw-r--r-- | test/formats/scripts/nested-redirecting.lnav | 5 | ||||
-rw-r--r-- | test/formats/scripts/redirecting.lnav | 6 | ||||
-rw-r--r-- | test/formats/sqldir/init.sql | 5 | ||||
-rw-r--r-- | test/formats/timestamp/format.json | 26 | ||||
-rw-r--r-- | test/formats/xmlmsg/format.json | 73 |
15 files changed, 459 insertions, 0 deletions
diff --git a/test/formats/collision/format.json b/test/formats/collision/format.json new file mode 100644 index 0000000..35c25c0 --- /dev/null +++ b/test/formats/collision/format.json @@ -0,0 +1,48 @@ +{ + "$schema": "https://lnav.org/schemas/format-v1.schema.json", + "zblued_log": { + "title": "blued", + "regex": { + "std": { + "pattern": "^(?<timestamp>\\w{3}\\s+\\d{1,2} \\d{2}:\\d{2}:\\d{2})(?: (?<log_hostname>[a-zA-Z0-9:][^ ]+[a-zA-Z0-9]))? blued(?:\\[(?<log_pid>\\d+)])?:(?<body>(?:.|\\n)*)$" + } + }, + "level-field": "body", + "level": { + "error": "(?:failed|failure|error)", + "warning" : "(?:warn|not responding|init: cannot execute)" + }, + "value" : { + "log_hostname" : { + "kind" : "string", + "collate" : "ipaddress", + "identifier" : true + } + }, + "sample" : [ + { + "line" : "Apr 4 20:02:32 Tim-Stacks-iMac.local blued[59]: Release the WiFi lock" + } + ] + }, + "xerror_log" : { + "title" : "Common Error Log", + "description" : "The default web error log format for servers like Apache.", + "regex" : { + "cups" : { + "pattern" : "^(?<level>\\w) \\[(?<timestamp>[^\\]]+)\\] (?<body>.*)" + } + }, + "level-field": "level", + "level" : { + "error" : "E", + "warning" : "W", + "info" : "I" + }, + "sample" : [ + { + "line" : "E [08/Jun/2013:11:28:58 -0700] Unknown directive BrowseOrder on line 22 of /private/etc/cups/cupsd.conf." + } + ] + } +} diff --git a/test/formats/customlevel/format.json b/test/formats/customlevel/format.json new file mode 100644 index 0000000..dde41fe --- /dev/null +++ b/test/formats/customlevel/format.json @@ -0,0 +1,25 @@ +{ + "$schema": "https://lnav.org/schemas/format-v1.schema.json", + "leveltest_log": { + "description": "Log format used for testing levels", + "regex": { + "line": { + "pattern": "^(?<timestamp>\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}) (?<level>[^ ]+) (?<body>.*)$" + } + }, + "level": { + "trace": "trace", + "debug": "debug", + "debug2": "debug2", + "debug3": "debug3", + "info": "info", + "warning": "warn", + "fatal": "fatal" + }, + "sample": [ + { + "line": "2016-06-30 12:00:01 trace tracemessage" + } + ] + } +} diff --git a/test/formats/jsontest-subsec/format.json b/test/formats/jsontest-subsec/format.json new file mode 100644 index 0000000..8469c7f --- /dev/null +++ b/test/formats/jsontest-subsec/format.json @@ -0,0 +1,27 @@ +{ + "$schema": "https://lnav.org/schemas/format-v1.schema.json", + "subsec_json_log": { + "title": "JSON Log with subsecond field", + "json": true, + "file-pattern": "logfile_json_subsec\\.json", + "line-format": [ + { + "field": "__timestamp__" + }, + " ", + { + "field": "msg" + } + ], + "timestamp-field": "instant/epochSecond", + "subsecond-field": "instant/nanoOfSecond", + "subsecond-units": "nano", + "body-field": "msg", + "value": { + "instant": { + "kind": "json", + "hidden": true + } + } + } +}
\ No newline at end of file diff --git a/test/formats/jsontest/format.json b/test/formats/jsontest/format.json new file mode 100644 index 0000000..78300e9 --- /dev/null +++ b/test/formats/jsontest/format.json @@ -0,0 +1,36 @@ +{ + "$schema": "https://lnav.org/schemas/format-v1.schema.json", + "test_log" : { + "title" : "Test JSON Log", + "json" : true, + "file-pattern" : "logfile_json\\.json", + "description" : "Test config", + "line-format" : [ + "\n[", + { "field" : "ts" }, + "] ", + { "field" : "lvl" }, + " ", + { "field" : "msg" } + ], + "level-field" : "lvl", + "timestamp-field": "ts", + "body-field" : "msg", + "value" : { + "msg" : { + "rewriter" : ";SELECT :msg || 'bork bork bork'" + }, + "arr" : { + "kind" : "json" + }, + "obj" : { + "kind" : "json" + }, + "user" : { + "kind" : "string", + "identifier" : true, + "rewriter" : "|rewrite-user" + } + } + } +} diff --git a/test/formats/jsontest/lnav-logstash.json b/test/formats/jsontest/lnav-logstash.json new file mode 100644 index 0000000..27f9239 --- /dev/null +++ b/test/formats/jsontest/lnav-logstash.json @@ -0,0 +1,47 @@ +{ + "$schema": "https://lnav.org/schemas/format-v1.schema.json", + "logstash_dam": { + "title": "Logstash Java JSON", + "url": "https://github.com/logstash/logstash-logback-encoder", + "description": "Log format for DAM Logstash JSON", + "json": true, + "hide-extra": false, + "file-pattern": "\\.clog.*", + "multiline": false, + "line-format": [ + { "field" : "@timestamp" }, + " ", + { "field" : "ipaddress" }, + " ", + { "field" : "message" }, + " ", + { "field" : "stack_trace", "default-value" : "" } + ], + "timestamp-field" : "@timestamp", + "body-field" : "message", + "level-field" : "level", + "level" : { + "trace" : "TRACE", + "debug" : "DEBUG", + "info" : "INFO", + "error" : "ERROR", + "warning" : "WARN" + }, + "value" : { + "logger_name" : { + "kind" : "string", + "identifier" : true + }, + "ipaddress" : { + "kind" : "string", + "identifier" : true + }, + "level_value" : { + "hidden": true + }, + "stack_trace" : { + "kind" : "string" + } + } + } +} diff --git a/test/formats/jsontest/rewrite-user.lnav b/test/formats/jsontest/rewrite-user.lnav new file mode 100644 index 0000000..e34aa78 --- /dev/null +++ b/test/formats/jsontest/rewrite-user.lnav @@ -0,0 +1,2 @@ + +;SELECT 'mailto:' || :user diff --git a/test/formats/jsontest2/format.json b/test/formats/jsontest2/format.json new file mode 100644 index 0000000..167aa0f --- /dev/null +++ b/test/formats/jsontest2/format.json @@ -0,0 +1,49 @@ +{ + "$schema": "https://lnav.org/schemas/format-v1.schema.json", + "json_log2": { + "title": "Test JSON Log with integer levels", + "json": true, + "file-pattern": "logfile_.*json2\\.json", + "description": "Test config", + "line-format": [ + { + "field": "ts" + }, + " ", + { + "field": "ts", + "timestamp-format": "abc %S def" + }, + " ", + { + "field": "lvl", + "min-width": 5 + }, + " ", + { + "field": "cl", + "max-width": 5 + }, + " ", + { + "field": "msg" + } + ], + "level-field": "lvl", + "level": { + "info": 0, + "error": 10 + }, + "timestamp-field": "ts", + "body-field": "msg", + "value": { + "user": { + "kind": "string", + "identifier": true + }, + "cl": { + "kind": "string" + } + } + } +} diff --git a/test/formats/jsontest3/format.json b/test/formats/jsontest3/format.json new file mode 100644 index 0000000..63cc2a6 --- /dev/null +++ b/test/formats/jsontest3/format.json @@ -0,0 +1,75 @@ +{ + "$schema": "https://lnav.org/schemas/format-v1.schema.json", + "json_log3": { + "title": "Test JSON Log Format", + "description": "Test JSON Log Format", + "file-pattern": "logfile_.*json3\\.json", + "json": true, + "hide-extra": true, + "convert-to-local-time": true, + "line-format": [ + { + "field": "__timestamp__" + }, + " ", + { + "field": "client_ip" + }, + " ", + { + "field": "request/method" + }, + " ", + { + "field": "response/status" + }, + " ", + { + "field": "request/uri" + } + ], + "value": { + "started_at": { + "kind": "integer", + "identifier": true + }, + "client_ip": { + "kind": "string", + "identifier": true + }, + "request/method": { + "kind": "string", + "identifier": true + }, + "request/uri": { + "kind": "string", + "identifier": true + }, + "request/size": { + "kind": "integer", + "identifier": false, + "hidden": true + }, + "response/status": { + "kind": "string" + }, + "details1": { + "hidden": true + }, + "details2": { + "hidden": true + }, + "details3": { + "hidden": true + } + }, + "timestamp-field": "started_at", + "timestamp-divisor": 1000, + "level-field": "response/status", + "level": { + "info": "2\\d+", + "warning": "4\\d+", + "critical": "5\\d+" + } + } +} diff --git a/test/formats/nestedjson/format.json b/test/formats/nestedjson/format.json new file mode 100644 index 0000000..afa6b08 --- /dev/null +++ b/test/formats/nestedjson/format.json @@ -0,0 +1,32 @@ +{ + "$schema": "https://lnav.org/schemas/format-v1.schema.json", + "ntest_log": { + "title": "Test JSON Log", + "json": true, + "file-pattern": "logfile_(nested|invalid)_json\\d*\\.json", + "description": "Test config", + "line-format": [ + { + "field": "ts" + }, + " ", + { + "field": "/@fields/lvl" + }, + " ", + { "field" : "@fields/msg" } + ], + "level-field" : "/@fields/lvl", + "timestamp-field": "ts", + "body-field" : "@fields/msg", + "value" : { + "@fields/user" : { + "kind" : "string", + "identifier" : true + }, + "@fields/trace#" : { + "kind" : "string" + } + } + } +} diff --git a/test/formats/scripts/multiline-echo.lnav b/test/formats/scripts/multiline-echo.lnav new file mode 100644 index 0000000..6913088 --- /dev/null +++ b/test/formats/scripts/multiline-echo.lnav @@ -0,0 +1,3 @@ +;SELECT 'World' as name +:echo Hello, ${name}! +Goodbye, ${name}! diff --git a/test/formats/scripts/nested-redirecting.lnav b/test/formats/scripts/nested-redirecting.lnav new file mode 100644 index 0000000..785c605 --- /dev/null +++ b/test/formats/scripts/nested-redirecting.lnav @@ -0,0 +1,5 @@ +:echo HOWDY! +:redirect-to hw2.txt +:echo HELLO, WORLD! +:redirect-to +:echo GOODBYE, WORLD! diff --git a/test/formats/scripts/redirecting.lnav b/test/formats/scripts/redirecting.lnav new file mode 100644 index 0000000..84b42c2 --- /dev/null +++ b/test/formats/scripts/redirecting.lnav @@ -0,0 +1,6 @@ +:echo Howdy! +:redirect-to hw.txt +:echo Hello, World! +|nested-redirecting +:redirect-to +:echo Goodbye, World! diff --git a/test/formats/sqldir/init.sql b/test/formats/sqldir/init.sql new file mode 100644 index 0000000..4e17034 --- /dev/null +++ b/test/formats/sqldir/init.sql @@ -0,0 +1,5 @@ + +CREATE VIEW web_status AS + SELECT group_concat(cs_uri_stem), sc_status FROM access_log group by sc_status; + +INSERT into lnav_view_filters VALUES ("log", 5, 0, "in", "regex", "credential status"); diff --git a/test/formats/timestamp/format.json b/test/formats/timestamp/format.json new file mode 100644 index 0000000..2a3740a --- /dev/null +++ b/test/formats/timestamp/format.json @@ -0,0 +1,26 @@ +{ + "$schema": "https://lnav.org/schemas/format-v1.schema.json", + "epoch_log": { + "title": "epoch timestamp test", + "regex": { + "std": { + "pattern": "^(?<timestamp>\\d+) (?<body>.*)$" + }, + "non_epoch": { + "pattern": "^(?<timestamp>\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}\\.\\d+) (?<body>.*)$" + } + }, + "timestamp-format": [ + "%i", + "%Y-%m-%d %H:%M:%S.%f" + ], + "sample": [ + { + "line": "1428634687123 Hello, World!" + }, + { + "line": "2022-09-10 19:57:36.123456 Hello, World" + } + ] + } +} diff --git a/test/formats/xmlmsg/format.json b/test/formats/xmlmsg/format.json new file mode 100644 index 0000000..efd6f42 --- /dev/null +++ b/test/formats/xmlmsg/format.json @@ -0,0 +1,73 @@ +{ + "$schema": "https://lnav.org/schemas/format-v1.schema.json", + "xml_msg_log": { + "title": "", + "description": "", + "regex": { + "std": { + "pattern": "^\\[(?<timestamp>\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2},\\d{3})\\]\\s+(?<level>\\w+)\\s+\\[(?<module>[^:]*):(?<line>\\d+)\\]\\s*(?<body>[^\\n]*)\\n?(?<msg_data>.*)" + } + }, + "level": { + "critical": "CRITICAL", + "error": "ERROR", + "warning": "WARNING", + "info": "INFO", + "debug": "DEBUG" + }, + "value": { + "module": { + "kind": "string", + "identifier": true, + "description": "Python source module which emitted log entry", + "rewriter": ";SELECT ''" + }, + "line": { + "kind": "integer", + "description": "Line number – in the module – where log entry was emitted" + }, + "msg_data": { + "kind": "xml", + "rewriter": ";SELECT node_path FROM xpath('//*', :msg_data)" + } + }, + "highlights": { + "client_id": { + "pattern": "(?<=>)\\d+(?=<\/client>)", + "color": "Orange1", + "underline": true + }, + "reply_error": { + "pattern": "(?<=<result>)ERROR(?=</result>)", + "color": "Red1" + }, + "request": { + "pattern": "<request[^>]*>", + "color": "Green" + }, + "reply": { + "pattern": "<head[^>]*>", + "color": "Gold1" + } + }, + "tags": { + "xml-req": { + "pattern": "Full request text:" + } + }, + "sample": [ + { + "line": "[2020-12-10 06:56:41,477] INFO [m:108] Calling 'x' with params:", + "level": "info" + }, + { + "line": "[2020-12-10 06:56:41,092] DEBUG [m:69] Full request text:\n<?xml version='1.0' encoding='iso-8859-2'?>\n<a-request>\n <head>\n x\n </head>\n <source>\n x\n </source>\n <request>\n <name>\n x\n </name>\n </request>\n</a-request>\n", + "level": "debug" + }, + { + "line": "[2020-12-10 06:56:41,099] DEBUG [m:85] Full reply text:\n<?xml version='1.0' encoding='iso-8859-2'?>\n<a-reply>\n <head>\n x\n </head>\n <reply>\n <status>\n <result>OK</result>\n </status>\n <name>\n x\n </name>\n </reply>\n <technical-track>\n x\n </technical-track>\n</a-reply>\n", + "level": "debug" + } + ] + } +}
\ No newline at end of file |