lnav icon indicating copy to clipboard operation
lnav copied to clipboard

How to set a permanant time_offset?

Open pnoeric opened this issue 5 years ago • 6 comments

I know I can set the time_offset every time I run lnav, but that's a hassle.

I tried updating the setting in the SQL lnav_file but that also doesn't appear to persist across sessions.

I checked the docs but couldn't find any more clues. What's the secret? ;-) Can I have lnav permanently remember this setting? Or at least pass it on the command line?

pnoeric avatar May 26 '20 16:05 pnoeric

No luck eh?

pnoeric avatar Jun 10 '20 07:06 pnoeric

What version of lnav are you using? The offset is supposed to be saved in the session, so it might be a bug if that is not happening. Can you provide an lnav debug log (pass -d /path/to/log on the command-line) to help me figure out what might be happening.

Can I ask what are you using the time_offset for? Are you trying to adjust for the timezone or small differences in logs between different machines?

tstack avatar Jun 10 '20 15:06 tstack

Hey Tim, thank you for this reply... I'll be happy to share that info but let me ask, when I press ctrl-R to reset lnav, does that also reset the time offset? Because I use ctrl-R all the time. ;-) So maybe that's the issue with it not persisting.

I'm using it only because my server is in GMT (and I don't want to change that), but I don't live in GMT and I would like to see the logged events in my own time zone, that's all.

pnoeric avatar Jun 10 '20 15:06 pnoeric

when I press ctrl-R to reset lnav, does that also reset the time offset? Because I use ctrl-R all the time. ;-)

Yeah, CTRL-R does clear the time offset (ref: https://github.com/tstack/lnav/blob/4250fe9c6796a6c136341b85aa8a81eeb78450b4/src/session_data.cc#L1421).

I'm using it only because my server is in GMT (and I don't want to change that), but I don't live in GMT and I would like to see the logged events in my own time zone, that's all.

A log format can be set to convert timestamps to local time when it's known that the timestamps are always UTC. But, that doesn't really work for cases like this... seems like something that should be added to lnav.

tstack avatar Jun 10 '20 16:06 tstack

Ah ok. I could adjust my log format (I see you have excellent docs for that)... but yeah, I look at a few different log formats so I'd have to change several formatters and override your defaults that already work perfectly.

So yeah, maybe a global time-offset option, unaffected by ctrl-R, is the right answer. I hope I am not creating work for you! hehe

pnoeric avatar Jun 10 '20 16:06 pnoeric

Hey, I guess this is kind of an old issue, but I found it looking for kind of the opposite thing — is there some way I can reset the time offset without ctrl-R ? I sometimes just want to undo my timestamp changes and I don't remember exactly what the original times were, but I'd like to keep my bookmarks, filters etc.

FWIW, in my experience the time offset does survive restarts of a session, and I haven't been able to reset it in one case even with ctrl-R due to lnav crashing — which I should try to get a minimal repro of and open a new issue.

Anyway, I guess I wanted to see if there's some way to reset just the time offset, and if not I can file a new issue to request it (or to document it, if there is already a way to do it).

ian-h-chamberlain avatar Jan 11 '24 20:01 ian-h-chamberlain