lnav icon indicating copy to clipboard operation
lnav copied to clipboard

Missing show/hide-fields command in :save-session-to

Open ConorMurphy21 opened this issue 1 year ago • 4 comments

lnav version I believe latest

Describe the bug :save-session writes a list of commands, including :show-fields and hide-fields to a json file in the lnav home directory. But when calling :save-session-to which produces an lnav file, these commands are not added to the output session file.

To Reproduce

  1. run :hide-fields body command
  2. run :save-session-to /tmp/sesh.lnav
  3. Observer no :hide-fields body in the /tmp/sesh.lnav

ConorMurphy21 avatar Dec 03 '24 18:12 ConorMurphy21

Hmm, I kinda want to say this was intentional. The :export-session-to command is more for sharing a session with another user. And, that user might not have the same preferences for the set of fields that are hidden/shown.

tstack avatar Jan 15 '25 19:01 tstack

Ok, I'm fine to close this if that's the intent, working around it isn't a big deal. Just to understand the use case though, I've been using the export-session-to command to look at similar log files with the same filters and stuff. For example testRun1/testLog and testRun2/testLog, where the content of the file should be very similar but it's useful to have to same filters to analyse the differences between a passing run log file vs a failing run log file.

ConorMurphy21 avatar Jan 28 '25 01:01 ConorMurphy21

look at similar log files with the same filters and stuff

Maybe take a look at #949 which has some discussion on setting up filters.

How about this, I could add the :hide-fields commands to the exported session script, but have them commented out by default. That way, it's easy to figure out the command.

Another option is to patch the format you're interested in to always have the fields hidden. For example, to patch syslog_log to hide the log_hostname field by default, you could use this patch file:

{
  "syslog_log": {
    "value": {
      "log_hostname": {
        "hidden": true
      }
    }
  }
}

tstack avatar Jan 30 '25 22:01 tstack

I think the commented out idea is a great idea! (and/or making it an optional parameter from the CLI)

I am aware of how scriptable LNAV is, I've written many scripts now to tune it to my liking. I've been super happy with it, awesome work! To get around this issue I've been relying on the fact the save-session command has this filter information included in the json. So I was just hoping to make my scripts feel a little less hacky, and also use tmp files so I don't fill up .config/lnav.

ConorMurphy21 avatar Jan 30 '25 22:01 ConorMurphy21

Seems like this has been sufficiently addressed thanks!

ConorMurphy21 avatar Sep 10 '25 22:09 ConorMurphy21