klogg icon indicating copy to clipboard operation
klogg copied to clipboard

[Feature] Cross line regex

Open SmallPepperZ opened this issue 4 years ago • 3 comments

I think that allowing regex highlighting to work across multiple lines would be a nice feature addition. For example, with the below output in a log

Ignoring exception in on_message
Traceback (most recent call last):
  File "/a/python/package", line 343, in _run_event
    await coro(*args, **kwargs)
  File "/a/code/file", line 141, in cool_function
    print(thisisanundefinedvariable)
NameError: name 'thisisanundefinedvariable' is not defined

You could use Ignoring exception[\s\S]+NameError:.+ to highlight the full traceback with a color you want to use for name errors, instead of using regex that only highlights the last line

SmallPepperZ avatar Jun 03 '21 16:06 SmallPepperZ

Hi, thanks for sharing an idea. Unfortunately, all string matching in klogg is done line-by-line. Major rework is needed for multiline matching.

variar avatar Jun 03 '21 18:06 variar

Merged previous similar request into this one

variar avatar Jun 03 '21 18:06 variar

This is indeed a workaround. I feel that most of use-cases should be covered by adding a setting for max lines to look at during matching, and then accumulate that many strings for each match. Need to be carefull when scattering match jobs to multiple threads, but doesn't seem too hard

variar avatar Jan 14 '23 19:01 variar