From 732e0e824e3bc7890b55c4d4e0a1556a0176498d Mon Sep 17 00:00:00 2001 From: Tim Stack Date: Fri, 5 Jul 2024 10:00:45 -0700 Subject: [PATCH] [formats] add rust env_logger and simple_logger formats --- NEWS.md | 4 +++- docs/source/formats.rst | 2 +- src/formats/formats.am | 2 ++ src/formats/simple_rs_log.json | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 src/formats/simple_rs_log.json diff --git a/NEWS.md b/NEWS.md index b32e7b3d..6df8f16c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -34,9 +34,11 @@ Features: * Keymap definitions can now bind to a function key using an identifier that starts with `f` followed by the number of the function key. +* Added log formats for the `env_logger` and `simple_logger` Rust + crates. Interface Changes: -* The "Gantt Chart" view has been renamed to "timeline". +* The "Gantt Chart" view has been renamed to "timeline." * In the timeline view, pressing `ENTER` will focus on the preview pane, so you can scroll through messages with the selected Op ID. diff --git a/docs/source/formats.rst b/docs/source/formats.rst index d57add1e..0b7995a0 100644 --- a/docs/source/formats.rst +++ b/docs/source/formats.rst @@ -84,7 +84,7 @@ Creating a Format Using Regex101.com (v0.11.0+) For plain-text log files, the easiest way to create a log format definition is to create the regular expression that recognizes log messages using https://regex101.com . Simply copy a log line into the test string input box -on the site and then start editing the regular expression. When building the +on the site and then start editing a PCRE2 regular expression. When building the regular expression, you'll want to use named captures for the structured parts of the log message. Any raw message text should be matched by a captured named "body". Once you have a regex that matches the whole log message, you can use diff --git a/src/formats/formats.am b/src/formats/formats.am index e522e821..b5446965 100644 --- a/src/formats/formats.am +++ b/src/formats/formats.am @@ -13,6 +13,7 @@ FORMAT_FILES = \ $(srcdir)/%reldir%/dpkg_log.json \ $(srcdir)/%reldir%/elb_log.json \ $(srcdir)/%reldir%/engine_log.json \ + $(srcdir)/%reldir%/env_logger_log.json \ $(srcdir)/%reldir%/error_log.json \ $(srcdir)/%reldir%/esx_syslog_log.json \ $(srcdir)/%reldir%/fsck_hfs_log.json \ @@ -33,6 +34,7 @@ FORMAT_FILES = \ $(srcdir)/%reldir%/procstate_log.json \ $(srcdir)/%reldir%/rails_log.json \ $(srcdir)/%reldir%/redis_log.json \ + $(srcdir)/%reldir%/simple_rs_log.json \ $(srcdir)/%reldir%/snaplogic_log.json \ $(srcdir)/%reldir%/sssd_log.json \ $(srcdir)/%reldir%/strace_log.json \ diff --git a/src/formats/simple_rs_log.json b/src/formats/simple_rs_log.json new file mode 100644 index 00000000..bd88e1b7 --- /dev/null +++ b/src/formats/simple_rs_log.json @@ -0,0 +1,32 @@ +{ + "$schema": "https://lnav.org/schemas/format-v1.schema.json", + "simple_rs_log": { + "title": "simple_logger format", + "description": "Format file for Rust's simple_logger crate", + "url": [ + "https://docs.rs/simple_logger/latest/simple_logger/" + ], + "regex": { + "std": { + "pattern": "^(?\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{9}[^\\s]+)\\s+(?\\w+)\\s+\\[(?\\w+)\\]\\s+(?.*)$" + } + }, + "value": { + "level": { + "kind": "string" + }, + "module": { + "kind": "string", + "identifier": true + }, + "timestamp": { + "kind": "string" + } + }, + "sample": [ + { + "line": "2022-01-19T17:27:07.013874956Z WARN [logging_example] This is an example message." + } + ] + } +}