doublep / logview

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

Simple examples of custom formats and setup #28

Closed dmg46664 closed 5 years ago

dmg46664 commented 5 years ago

I'm having issues setting up which I'm working through, but it's not been obvious to me, partially because I'm not that familiar with Emacs. Having a couple of copy & paste example custom configurations would be useful on your main github page, which might also be adapted to answer questions:

I managed eventually to put the following in my spacemacs file.

 (setq logview-additional-submodes
      ("CUSTOM" . ((format  . "LEVEL, NAME, \"TIMESTAMP\", THREAD, \"[IGNORE] []")
                         (levels  . "SLF4J")
                         (aliases . ("Custom2")))
       )))

However it's not working (and the dangling double quote isn't a mistake), but it may also be due to the following: datetime--determine-system-timezone: Failed to determine system timezone; consider customizing ‘datetime-timezone’ variable

It doesn't guess my format correctly and when I select it it asks for the time format which I enter manually (as : yyyy-MM-dd HH:mm:ss.SSS after which I get the error message.

I imagine this is an Emacs for Windows issue?

I've just figured out that if I start typing "ISO 8601 datetime + millis" then I get the right alternative selection (thought i could start typing yyy), but then it fails with: logview-choose-submode: Internal error initializing submode ‘Custom2’ [2 times]

Looking forward to see the tool in action.

dmg46664 commented 5 years ago

I needed to obfuscate an example before pasting:

INFO, com.test.TestClass, "2019.03.29 04:39:11.227", pool-2-thread-11, "[SYSTEM] [] Setting up parameters for Blah"

dmg46664 commented 5 years ago

I've just realized I have an added complication of thread field potentially looking like Something.meaningfulPresumablyANameToTheThreadGivenByTheApp [0000000002] # pool-2-thread-5 or just pool-2-thread-5 if not available. :-(

That was actually on the first line for me.

doublep commented 5 years ago

Having a couple of copy & paste example custom configurations would be useful

I'm generally following the idea that users should use customization interface rather than Lisp code. Try M-x customize-group RET logview RET.

Does [ need escaping? (I think not given your default format).

No.

Does it need to be an exact match on whitespacing and surrounding characters? Presumably commas are allowable

Any whitespace in the pattern matches any whitespace in the actual line, but other characters have to be precisely as in the pattern.

Why does it need to understand the timezone? (See below)

Since recent versions there are commands like z A that need to understand how far apart two timestamps are. To do that correctly, timezone is needed (because of daytime-saving etc.).

However it's not working (and the dangling double quote isn't a mistake), but it may also be due to the following: datetime--determine-system-timezone: Failed to determine system timezone; consider customizing ‘datetime-timezone’ variable

datetime library fails to find the correct timezone for your system. As it says, consider customizing datetime-timezone variable

It doesn't guess my format correctly

I guess only because of the above error. If you tell datetime your system timezone, it should be able to guess (I hope).

I imagine this is an Emacs for Windows issue?

Rather datetime on Windows, but yes.

I've just realized I have an added complication of thread field potentially looking like Something.meaningfulPresumablyANameToTheThreadGivenByTheApp [0000000002] # pool-2-thread-5 or just pool-2-thread-5 if not available. :-(

I'm not sure I understand what you mean, but Logview should handle one set of matching parens (( + ) or [ + ]) in the names. Not more than one though.

Apteryks commented 2 years ago

Hello!

I also struggled a lot with specifying a submode for RobotFramework debugfile logs; I was getting difficult to understand errors. In the end, what worked was this:

(setq logview-additional-level-mappings
        '(("RobotFramework"
           (error       "FAIL")
       (warning     "WARNING")
       (information "INFO" "HTML")
       (debug       "DEBUG")
       (trace       "TRACE")
       (aliases "RF" "Robot")))

        logview-additional-timestamp-formats
        '(("RobotFramework"
           (java-pattern . "yyyyMMdd HH:mm:ss.SSS")
           (datetime-options :any-decimal-separator t)
           (aliases "Robot" "RF")))

        logview-additional-submodes
        '(("RobotFramework"
           (format . "TIMESTAMP - LEVEL - MESSAGE")
       (levels . "RobotFramework")
           (timestamp "RobotFramework")
       (aliases "RF" "Robot"))))

A couple of observations: sometimes the items of an alist must be pairs, sometimes proper lists, for example the format vs timestamp key in the above additional submodes definition. It'd be nice if everything was consistently using either.

Apteryks commented 2 years ago

The fact that the default timestamp formats are dynamically made made it harder than it should have been to specify one. Granted, I've now learned how to uso customize-group, which helped, but still, Elisp-formatted examples would be useful, I think.

doublep commented 2 years ago

It's basically always (KEY . VALUE). When it is a list, you can write it either as (KEY . (ELEMENT1 ELEMENT2...)) or as (KEY ELEMENT1 ELEMENT2...), just Lisp working that way.

Apteryks commented 2 years ago

I see, thank you for explaining; it seems reasonable.