doublep / logview

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

Timezone in timestamp #50

Closed eddiepierce closed 10 months ago

eddiepierce commented 10 months ago

Hey - I have a log line like below, however the "-05:00" is causing issues:

Inf-2023-09-07T16:27:03.479361-05:00-t@1169727-thread.C:stopThread:118=>Stopping thread

I've tried

(logview-additional-timestamp-formats
   '(("WithTimezone"
      (regexp . "[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{6}[+-][0-9]{2}:[0-9]{2}"))))

and

(logview-additional-timestamp-formats
   '(("WithTimezone"
      (java-pattern . "yyyy-MM-dd'T'HH:mm:ss.SSSSSSX"))))

however couldn't get either to work, with the latter giving the error message:

Warning (emacs): In Java timestamp pattern "yyyy-MM-dd'T'HH:mm:ss.SSSSSSX": Timezones are currently not supported

When I remove the "-05:00" I can get logview working. Thanks for creating such a great emacs mode!

doublep commented 10 months ago

I can get your submode recognized with this:

(with-eval-after-load 'logview
  (add-to-list 'logview-additional-submodes
               '("eddiepierce"
                 (format . "NAME-TIMESTAMP-t@THREAD=>MESSAGE")))
  (add-to-list 'logview-additional-timestamp-formats
               '("fixed-tz-offset"
                 (java-pattern . "yyyy-MM-dd'T'HH:mm:ss.SSSSSS-'05:00'"))))

Basically, make -05:00 a constant string part rather than part of timezone. You can also move it to submode definition.

But yeah, I should eventually make datetime recognize at least some way of encoding timezones, not the first time I get such complaint.

doublep commented 10 months ago

With datetime 0.9 your timestamps can be parsed using pattern yyyy-MM-dd'T'HH:mm:ss.SSSSSSxxx (see Java pattern documentation for why "triple x"). You need to add this to logview-additional-timestamp-formats.