lnav icon indicating copy to clipboard operation
lnav copied to clipboard

Permit wrapping of single fields

Open corrado9999 opened this issue 5 years ago • 1 comments

It would be useful to add as an overflow method "wrap", wrapping long fields on multiple lines. The enable-word-wrap command wraps full lines, but it messes up fields alignment. Fields well aligned improve the readability of well structured log files like JSON.

The use case: I have a JSON log file with quite common fields (timestamp, level, file, line number, hostname, stacktrace, message, ...); I wrote a custom log format to pretty align fields (some are fix-width, some can be easily either padded or truncated) but stacktrace and message have, of course, a variable length. As a workaround I put them at the end but this is suboptimal as:

  1. stacktrace and message cannot be aligned (actually they could if they were mutually exclusive, but in the general case with two variable-length fields you cannot get alignement)
  2. I have to scroll to the very end of line in order to see the message, which is tedious, I could miss important messages if I forget and anyway I should also move the timestamp in order to see it near the message
  3. for errors, the stacktrace usually have newlines in it (it would be pretty hard to read if it has not); by putting it at the end of the line it wraps at the beginning after a newline, thus I need to scroll back and forth

I know I could use a SQL query for making a nice table, but ";SELECT * FROM my_log" seems to me a too long command for such thing, and it is not persistent.

corrado9999 avatar Mar 30 '20 11:03 corrado9999

Well, this slipped through the cracks... sorry. I don't know if you care any more, but I wanted to mention that if you leave the field out of the line-format, it will be displayed on the following lines. In the following screenshot, exc is a defined value that is not in the line-format, so it get displayed more like a key/value pair:

Image

tstack avatar Feb 10 '25 23:02 tstack