branch: elpa/logview commit 181eec1aa62429b77f5ae053559b5249bbb7abfb Author: Paul Pogonyshev <pogonys...@gmail.com> Commit: Paul Pogonyshev <pogonys...@gmail.com>
Expand list of standard submodes and timestamps so that some files in '/var/log' are picked up automatically. --- README.md | 3 ++- logview.el | 43 ++++++++++++++++++++++++++++++++----------- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 834cb8642e..b4c4029215 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,8 @@ The mode is meant to be operated in read-only buffer, so all the command bindings lack modifiers. Out-of-the-box the mode should be able to parse standard SLF4J (Log4j, -Logback) files as long as they use ISO 8601 timestamps. +Logback) files as long as they use ISO 8601 timestamps and certain +UNIX files in `/var/log`. ### Submodes diff --git a/logview.el b/logview.el index efe48ecc5f..7d40d5ff01 100644 --- a/logview.el +++ b/logview.el @@ -283,7 +283,9 @@ You can temporarily change this on per-buffer basis using (defvar logview-std-submodes '(("SLF4J" . ((format . "TIMESTAMP [THREAD] LEVEL NAME - ") (levels . "SLF4J") - (aliases . ("Log4j" "Log4j2" "Logback"))))) + (aliases . ("Log4j" "Log4j2" "Logback")))) + ;; We misuse thread as a field for hostname. + ("UNIX" . ((format . "TIMESTAMP THREAD NAME: ")))) "Alist of standard submodes. This value is used as the fallback for customizable `logview-additional-submodes'.") @@ -305,16 +307,35 @@ This alist value is used as the fallback for customizable `logview-additional-level-mappings'.") (defvar logview-std-timestamp-formats - '(("ISO 8601 datetime + millis" . (; Silently handle both common decimal separators (dot and comma). - (regexp . "[0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} [0-9]\\{2\\}:[0-9]\\{2\\}:[0-9]\\{2\\}[.,][0-9]\\{3\\}") - (aliases . ("yyyy-MM-dd HH:mm:ss.SSS")))) - ("ISO 8601 datetime" . ((regexp . "[0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} [0-9]\\{2\\}:[0-9]\\{2\\}:[0-9]\\{2\\}") - (aliases . ("yyyy-MM-dd HH:mm:ss")))) - ("ISO 8601 time only + millis" . (; Silently handle both common decimal separators (dot and comma). - (regexp . "[0-9]\\{2\\}:[0-9]\\{2\\}:[0-9]\\{2\\}[.,][0-9]\\{3\\}") - (aliases . ("HH:mm:ss.SSS")))) - ("ISO 8601 time only" . ((regexp . "[0-9]\\{2\\}:[0-9]\\{2\\}:[0-9]\\{2\\}") - (aliases . ("HH:mm:ss"))))) + ;; General notices: we silently handle both common decimal + ;; separators (dot and comma). In several cases there is optional + ;; space if the day/hour number is single-digit. + (let ((HH:mm:ss "[012][0-9]:[0-5][0-9]:[0-5][0-9]") + (h:mm:ss "[ 01]?[0-9]:[0-5][0-9]:[0-5][0-9]") + (.SSS "[.,][0-9]\\{3\\}") + (a " [AP]M") + (yyyy-MM-dd "[0-9]\\{4\\}-[01][0-9]-[0-3][0-9]") + (MMM (regexp-opt '("Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" "Dec"))) + (d "[ 1-3]?[0-9]") + ) + (list (list "ISO 8601 datetime + millis" + (cons 'regexp (concat yyyy-MM-dd " " HH:mm:ss .SSS)) + (list 'aliases "yyyy-MM-dd HH:mm:ss.SSS")) + (list "ISO 8601 datetime" + (cons 'regexp (concat yyyy-MM-dd " " HH:mm:ss)) + (list 'aliases "yyyy-MM-dd HH:mm:ss")) + (list "ISO 8601 time only + millis" + (cons 'regexp (concat HH:mm:ss .SSS)) + (list 'aliases "HH:mm:ss.SSS")) + (list "ISO 8601 time only" + (cons 'regexp HH:mm:ss) + (list 'aliases "HH:mm:ss")) + (list "MMM d HH:mm:ss" + (cons 'regexp (concat MMM " " d " " HH:mm:ss))) + (list "MMM d h:mm:ss a" + (cons 'regexp (concat MMM " " d " " h:mm:ss a))) + (list "h:mm:ss a" + (cons 'regexp (concat h:mm:ss a))))) "Alist of standard timestamp formats. This value is used as the fallback for customizable `logview-additional-timestamp-formats'.")