From 245c6523d454e5061fd2db059d84c20e5ef0f57b Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Fri, 20 May 2022 14:10:37 +0200 Subject: [PATCH] Update lnav note with custom format --- notebook/Linux/Tools/Taskwarrior.md | 2 +- notebook/Linux/Tools/lnav.md | 48 ++++++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/notebook/Linux/Tools/Taskwarrior.md b/notebook/Linux/Tools/Taskwarrior.md index dab4111..0acc421 100644 --- a/notebook/Linux/Tools/Taskwarrior.md +++ b/notebook/Linux/Tools/Taskwarrior.md @@ -2,4 +2,4 @@ tag: task --- # Taskwarrior -[Taskwarrior](https://taskwarrior.org/) is a #terminal task manager \ No newline at end of file +[Taskwarrior](https://taskwarrior.org/) is a #terminal task manager diff --git a/notebook/Linux/Tools/lnav.md b/notebook/Linux/Tools/lnav.md index d788d12..1587d6e 100644 --- a/notebook/Linux/Tools/lnav.md +++ b/notebook/Linux/Tools/lnav.md @@ -3,4 +3,50 @@ tags: debugging logs terminal --- # LNav -[lnav](https://lnav.org) is a #terminal logfile viewer based on #curses. \ No newline at end of file +[lnav](https://lnav.org) is a #terminal logfile viewer based on #curses. + +## Custom Formats: +lnav supports adding [custom format descriptions](https://docs.lnav.org/en/latest/formats.html) to parse Log formats that lack built-in support. +```json +{ + "$schema": "https://lnav.org/schemas/format-v1.schema.json", + "example": { + "title": "Example Format", + "description": "A generic example for how to make a custom lnav Format", + "url": "https://example.org/", + "regex": { + "line": { + "pattern": "^(?[\\d-]{10} [\\d:]{8}) [-+]\\d{4} \\[(?[A-Z]+)\\] (?[^:]+):(?\\d+) -- (?.*)$" + } + }, + "timestamp-format": "%Y-%m-%d %H:%M:%S %z", + "level-field": "level", + "level": { + "fatal": "FATAL", + "error": "ERROR", + "warning": "WARNING", + "info": "INFO", + "debug": "DEBUG" + }, + "value": { + "src_line": { + "kind": "integer", + "foreign-key": true + }, + "src_file": { + "kind": "string", + "identifier": true, + "foreign-key": true + } + }, + "sample": [ + { "line": "2022-05-20 11:10:54 +0200 [FATAL] test.lua:8 -- Fatal" }, + { "line": "2022-05-20 11:10:54 +0200 [ERROR] test.lua:9 -- Error" }, + { "line": "2022-05-20 11:10:54 +0200 [WARN] test.lua:10 -- Warn" }, + { "line": "2022-05-20 11:10:54 +0200 [INFO] test.lua:11 -- Info" }, + { "line": "2022-05-20 11:10:54 +0200 [DEBUG] test.lua:12 -- Debug" } + ] + } +} + +``` \ No newline at end of file