lazydocker icon indicating copy to clipboard operation
lazydocker copied to clipboard

Clear logs

Open Tam opened this issue 2 years ago • 11 comments

It'd be really useful to be able to clear the logs view and only show new items as they come in.

This is possible when viewing the logs independently (i.e. via the m keybind) and using the clear command to clear the terminal, but I often find myself jumping between containers to check the logs, so being able to do this within the lazydocker context would be handy!

Tam avatar Nov 21 '22 14:11 Tam

I agree this would be a great feature. It might also be quite easy i.e. just press a key and then clear the main view. I'm gonna put a good-first-issue label on this. If you wanna take a stab at this @Tam lemme know and I can point you to the right places in the code to make the changes

jesseduffield avatar Nov 21 '22 23:11 jesseduffield

It's been a minute since I last used Go @jesseduffield, but sure if you can point me in the right direction I'll try to find time soon to give it a shot!

Tam avatar Nov 22 '22 11:11 Tam

Awesome :)

So you'll want to add a keybinding handler in pkg/gui/main_panel.go called handleClearMain

func (gui *Gui) handleClearMain() error {
	if gui.popupPanelFocused() {
		return nil
	}

    gui.Views.Main.Clear()
	return nil
}

and then you'll want to reference it from pkg/gui/keybindings.go like so:

		{
			ViewName: "main",
			Key:      gocui.KeyCtrlL,
			Modifier: gocui.ModNone,
			Handler:  wrappedHandler(gui.handleClearMain),
			Description: gui.Tr.ClearMain,
		},

You'll also need to add the keybinding's help text to pkg/i18n/english.go (that's what the gui.Tr.ClearMain thing refers to).

I'd see how that goes. We'll likely need to tweak it but that's a good starting spot

jesseduffield avatar Nov 23 '22 06:11 jesseduffield

@jesseduffield, is anyone actively working on this issue right now?

26tanishabanik avatar Nov 28 '22 19:11 26tanishabanik

Did you get a chance to start on this @Tam ? If you want to give it a go @26tanishabanik I'm happy to assign you

jesseduffield avatar Nov 28 '22 23:11 jesseduffield

Did you get a chance to start on this @Tam ? If you want to give it a go @26tanishabanik I'm happy to assign you

I can give it a try @jesseduffield , though I have a question, how do I setup the local dev environment, is there specific doc for that?

26tanishabanik avatar Nov 29 '22 07:11 26tanishabanik

@jesseduffield it’s probably gonna be a while before I have time, happy to let @26tanishabanik take the reins 👍

Tam avatar Nov 29 '22 08:11 Tam

ClearMain

@jesseduffield , what does KeyCtrlL mean?

26tanishabanik avatar Nov 30 '22 13:11 26tanishabanik

I'd guess it's ctrl+L.

mark2185 avatar Nov 30 '22 13:11 mark2185

I'd guess it's ctrl+L.

Thanks @mark2185

26tanishabanik avatar Nov 30 '22 13:11 26tanishabanik

@jesseduffield , ctrl+L is working, I am able to clear the logs, after moving my cursor to the logs tab

26tanishabanik avatar Nov 30 '22 13:11 26tanishabanik