doublep / logview

Emacs mode for viewing log files
GNU General Public License v3.0
154 stars 18 forks source link

Epoch Time Support #39

Closed erichlf closed 3 years ago

erichlf commented 3 years ago

I am trying to get my logs to be recognized and at the moment it seems like the big issue is the time stamp. My company uses epoch time (sorta). The time stamp is "10DigitEpochTime us". The number of micro seconds will always have 6 entries, either numbers or spaces (i.e. no leading zeros). I tried the following, but whenever I try to use it I am asked for a timestamp format.

(setq logview-additional-timestamp-formats
     '(("CUSTOM" (regexp . "[0-9]{10} [ 0-9]{6}")))
  )
(setq logview-additional-level-mappings
     '(("CUSTOM"
        (error "ERROR")
        (warning "WARN")
        (information "INFO")
        (debug "DEBUG")
        (trace)
        (aliases))))
(setq logview-additional-submodes
     '(("CUSTOM"
         (format . "[TIMESTAMP THREAD LEVEL]")
         (levels . "CUSTOM")
         (timestamp "CUSTOM")
         (aliases)))
  )
doublep commented 3 years ago

I believe you just need to add backslashes before curly brackets in the regexp. Emacs regexp syntax is weird like that.

erichlf commented 3 years ago

That seems to have been the problem with the timestamp. But logview doesn't seem to be able to find any log entries. The following is an example of a log entry:

[1602175902 539952 2704 DEBUG] Some sort of message

The first two sets of numbers are the timestamp the next set of numbers is the thread id and then the log level and finally the message.

doublep commented 3 years ago

Works for me. Note that debug-level entries are not highlighted by default.

Here is the config I used:

(setq logview-additional-timestamp-formats
     '(("CUSTOM" (regexp . "[0-9]\\{10\\} [ 0-9]\\{6\\}")))
  )
(setq logview-additional-level-mappings
     '(("CUSTOM"
        (error "ERROR")
        (warning "WARN")
        (information "INFO")
        (debug "DEBUG")
        (trace)
        (aliases))))
(setq logview-additional-submodes
     '(("CUSTOM"
         (format . "[TIMESTAMP THREAD LEVEL]")
         (levels . "CUSTOM")
         (timestamp "CUSTOM")
         (aliases)))
  )
erichlf commented 3 years ago

I forgot a slash. Thanks!