[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/logview 880675cc73 011/259: Make submode customization muc
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/logview 880675cc73 011/259: Make submode customization much more user-friendly by providing standard options for level mappings and timestamps. |
Date: |
Fri, 31 Jan 2025 07:01:48 -0500 (EST) |
branch: elpa/logview
commit 880675cc739396e4065872aaa8e4fe67f2a1c9ca
Author: Paul Pogonyshev <pogonyshev@gmail.com>
Commit: Paul Pogonyshev <pogonyshev@gmail.com>
Make submode customization much more user-friendly by providing standard
options for level mappings and timestamps.
---
logview.el | 165 +++++++++++++++++++++++++++++++++++--------------------------
1 file changed, 94 insertions(+), 71 deletions(-)
diff --git a/logview.el b/logview.el
index 3e0ac2fd53..a899cb1b18 100644
--- a/logview.el
+++ b/logview.el
@@ -41,6 +41,72 @@
(add-to-list 'auto-mode-alist '("\\.log\\(?:\\.[0-9]+\\)?\\'" . logview-mode))
+
+;;; Public variables.
+;; This needs to go before customization, since the values are used in
+;; compound widget types.
+
+(defvar logview-std-submodes
+ '(("SLF4J" . ((format . "TIMESTAMP [THREAD] LEVEL NAME - ")
+ (levels . "SLF4J")
+ (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'.")
+
+(defvar logview-std-level-mappings
+ '(("SLF4J" . ((error "ERROR")
+ (warning "WARN")
+ (information "INFO")
+ (debug "DEBUG")
+ (trace "TRACE")
+ (aliases "Log4j" "Log4j2" "Logback")))
+ ("JUL" . ((error "ERROR")
+ (warning "WARNING")
+ (information "INFO")
+ (debug "CONFIG" "FINE")
+ (trace "FINER" "FINEST"))))
+ "Standard mappings of actual log levels to mode's final levels.
+This alist value is used as the fallback for customizable
+`logview-additional-level-mappings'.")
+
+(defvar logview-std-timestamp-formats
+ ;; 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'.")
+
+
;;; Customization.
@@ -56,6 +122,33 @@
(when (and (eq major-mode 'logview-mode) (not (logview-initialized-p)))
(logview--guess-submode)))))
+(defvar logview--additional-submodes-type
+ (let* ((italicize (lambda (string) (propertize string 'face 'italic)))
+ (mapping-option (lambda (mapping)
+ (let ((name (car mapping))
+ (aliases (cdr (assq 'aliases (cdr mapping)))))
+ (list 'const
+ :tag (if aliases
+ (format "%s (aka: %s)" (funcall
italicize name) (mapconcat italicize aliases ", "))
+ (funcall italicize name))
+ name)))))
+ (list 'repeat (list 'cons '(string :tag "Name")
+ (list 'list :tag "Definition"
+ '(cons :tag "" (const :tag "Format:" format)
string)
+ (list 'set :inline t
+ (list 'cons :tag "" '(const :tag "Level
map:" levels)
+ (append '(choice)
+ (mapcar mapping-option
logview-std-level-mappings)
+ '((string :tag "Other
name"))))
+ (list 'cons :tag "" '(const :tag
"Timestamp:" timestamp)
+ (list 'choice
+ '(const :tag "Any supported"
nil)
+ (list 'repeat
+ (append '(choice)
+ (mapcar
mapping-option logview-std-timestamp-formats)
+ '((string :tag
"Other name"))))))
+ '(cons :tag "" (const :tag "Aliases:"
aliases) (repeat string))))))))
+
(defcustom logview-additional-submodes nil
"Association list of log submodes (file parsing rules).
@@ -97,13 +190,7 @@ aliases [optional]
Submode can have any number of optional aliases, which work just
as the name."
:group 'logview
- :type '(repeat (cons (string :tag "Name")
- (list :tag "Definition"
- (cons :tag "" (const :tag "Format:" format)
string)
- (set :inline t
- (cons :tag "" (const :tag "Level map:"
levels) string)
- (cons :tag "" (const :tag "Timestamp:"
timestamp) (repeat string))
- (cons :tag "" (const :tag "Aliases:"
aliases) (repeat string))))))
+ :type logview--additional-submodes-type
:set 'logview--set-submode-affecting-variable
:set-after '(logview-additional-timestamp-formats
logview-additional-level-mappings))
@@ -288,70 +375,6 @@ You can temporarily change this on per-buffer basis using
:group 'logview-faces)
-
-;;; Public variables.
-
-(defvar logview-std-submodes
- '(("SLF4J" . ((format . "TIMESTAMP [THREAD] LEVEL NAME - ")
- (levels . "SLF4J")
- (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'.")
-
-(defvar logview-std-level-mappings
- '(("SLF4J" . ((error "ERROR")
- (warning "WARN")
- (information "INFO")
- (debug "DEBUG")
- (trace "TRACE")
- (aliases "Log4j" "Log4j2" "Logback")))
- ("JUL" . ((error "ERROR")
- (warning "WARNING")
- (information "INFO")
- (debug "CONFIG" "FINE")
- (trace "FINER" "FINEST"))))
- "Standard mappings of actual log levels to mode's final levels.
-This alist value is used as the fallback for customizable
-`logview-additional-level-mappings'.")
-
-(defvar logview-std-timestamp-formats
- ;; 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'.")
-
-
;;; Internal variables and constants.
- [nongnu] elpa/logview d1798be8f1 231/259: Release logview 0.17.3, (continued)
- [nongnu] elpa/logview d1798be8f1 231/259: Release logview 0.17.3, ELPA Syncer, 2025/01/31
- [nongnu] elpa/logview 16e2d20906 198/259: Experimentally also test on macOS and Windows., ELPA Syncer, 2025/01/31
- [nongnu] elpa/logview 42ecd7d1b0 239/259: Make `logview-revert-buffer` cancel narrowing if the new contents seems to be completely different, e.g. after log rotation., ELPA Syncer, 2025/01/31
- [nongnu] elpa/logview a0eab50b55 067/259: Fix commit 92e305f converting error about missing 'logview.views' to a warning on Emacs 24 and 25 rather than silencing it completely; fixes #14., ELPA Syncer, 2025/01/31
- [nongnu] elpa/logview 96e207c7e7 102/259: Add commands to highlight entries in a view., ELPA Syncer, 2025/01/31
- [nongnu] elpa/logview 9784604caf 122/259: Added RFC 5424 levels, with tests. Closes #31., ELPA Syncer, 2025/01/31
- [nongnu] elpa/logview 95c1c8465a 123/259: Added submode for Apache Error Logs. Closes #34., ELPA Syncer, 2025/01/31
- [nongnu] elpa/logview 721c3953d5 019/259: Bump version because of major new feature., ELPA Syncer, 2025/01/31
- [nongnu] elpa/logview c6f3bde8da 030/259: Add two commands that are essentially one-time explicit invocations of the auto-revert modes., ELPA Syncer, 2025/01/31
- [nongnu] elpa/logview 30759b191b 086/259: During testing, treat all warnings as errors; should e.g. catch issue #14 if it re-appears., ELPA Syncer, 2025/01/31
- [nongnu] elpa/logview 880675cc73 011/259: Make submode customization much more user-friendly by providing standard options for level mappings and timestamps.,
ELPA Syncer <=
- [nongnu] elpa/logview 4ee5d0ef4b 051/259: Change mention of MELPA in README.md to prefer stable variant., ELPA Syncer, 2025/01/31
- [nongnu] elpa/logview 1ec5131eed 085/259: Brag about current Travis CI status in README.md., ELPA Syncer, 2025/01/31
- [nongnu] elpa/logview 5c88e7be0a 110/259: Make `logview--all-timestamp-formats' cache its results externally using `extmap'; important now that `datetime' switched to Java 9 and knows many more locales., ELPA Syncer, 2025/01/31
- [nongnu] elpa/logview a715f41651 153/259: Make usage of font lock mode support some more standard functionality, for the sake of possible derived modes (issue #43)., ELPA Syncer, 2025/01/31
- [nongnu] elpa/logview b37079f93c 159/259: Don't jump to section start when narrowing; instead, print section header in the echo area (also when using command `SPC')., ELPA Syncer, 2025/01/31
- [nongnu] elpa/logview 9bf89f7e62 178/259: Post-release version bump, ELPA Syncer, 2025/01/31
- [nongnu] elpa/logview e6d5a0a686 171/259: Improve Emacs responsiveness in cases where filters filter out almost everything., ELPA Syncer, 2025/01/31
- [nongnu] elpa/logview e5fe5d611c 184/259: Silence a byte-compilation warning in Emacs 30., ELPA Syncer, 2025/01/31
- [nongnu] elpa/logview 23c4e73831 196/259: Also test on Emacs 29.1., ELPA Syncer, 2025/01/31
- [nongnu] elpa/logview 12a33e026b 220/259: Also test on Emacs 29.2 and 29.3., ELPA Syncer, 2025/01/31