lnav icon indicating copy to clipboard operation
lnav copied to clipboard

Support for space padded log lines

Open ConorMurphy21 opened this issue 1 year ago • 3 comments

Some log formats are space padded (like how json_lines might be displayed).

so a line might look like

12:00:00 INFO something happened

These formats are mostly fine in lnav, the problem is you :hide-fields level then the format looks like this:

12:00:00 ⋮ something happened

Which can be especially space wasteful if you hide multiple fields.

I think this could be relatively easily fixed by adding a property like "padded": "left|right" to a format (either global or per value), and then using that to delete the space to the left or right of a value when hiding that field.

ConorMurphy21 avatar Feb 15 '25 03:02 ConorMurphy21

I think this is technically possible now if you use a capture that wraps around the level the white-space. You can then hide that. Something like:

(?<level_column>(?<level>INFO|WARN|ERROR)\s+)

tstack avatar Feb 15 '25 14:02 tstack

Interesting, yeah that's useful to know, I was considering including the space in the field itself but then it wouldn't parse properly. I think there still could be room to improve to improve this use case but that is a decent option. I guess that solution could allow a more generic handling of any formatting that is around a field.

With this solution it would be nice to have :show/hide-fields level hide the level_column as well / instead. And also to keep wrappers hidden in sql vtables so that results don't get bloated with doubled columns.

ConorMurphy21 avatar Feb 16 '25 04:02 ConorMurphy21

I've pushed a change that is somewhat related to this, see -- https://github.com/tstack/lnav/issues/375#issuecomment-2692346456

tstack avatar Mar 01 '25 18:03 tstack