doublep / logview

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

Custom log format - how to deal with more dynamic log infos? #8

Closed mosquito-magnet closed 7 years ago

mosquito-magnet commented 7 years ago

As I understand it, we can use the 4 known part types THREAD, NAME, TIMESTAMP and LEVEL, everything else in the format string will be interpreted literally.

I frequently deal with logs (on whose format I have no influence), which have lots of dynamic info on top of that. An example: Tier-Name App-Name Server-Name Session-Id Timestamp Level .... ServiceLayer MyApp SLServer1 12341234156131 2017-01-17 10:00:12.1234 DEBUG .... Frontend MyApp FEServer2 12341234156132 2017-01-17 10:00:12.1234 DEBUG ....

Is it possible to match this format with the current version? If not, is it possible to get a new part, eg. FILLER or IGNORE, which matches a block of non-whitespace?

doublep commented 7 years ago

Currently not possible with Logview. However, I created a patch based on your suggestion. With this patch (already committed) your example is parseable with the following submode:

NAME THREAD IGNORED IGNORED TIMESTAMP LEVEL

Of course you can change what is mapped to name/thread as it makes sense to you. Ignored parts will not be highlighted and, most importantly, will not be filterable. They are there only for matching.

Also don't forget to add a special timestamp format, as Logview will not recognize anything with 4 decimals as a timestamp by default (only 0, 3 or 6).

Finally, remember that currently Logview matches the very first buffer line only. If you have any headers (I'm not sure about the first line in your example), buffer submode will not be determined.

I tested the patch and it worked for me (tm) with your example, but feel free to reopen if you have more problems.

mosquito-magnet commented 7 years ago

Wow, that was fast :) Works great, thanks a lot!