Skip to content
This repository has been archived by the owner on Oct 13, 2021. It is now read-only.

Debugging

Marcus Olsson edited this page Jan 6, 2018 · 2 revisions

Sometimes, especially if your developing tui-go, you want to log internal events to better understand why yours aren't being handled. By default, tui-go doesn't output any logs, but you can set the default logger using tui.SetLogger, which accepts a standard logger, to output logs to a destination of your choice.

Example:

f, err := os.Create("debug.log")
if err != nil {
	// ...
}
defer f.Close()

logger := log.New(f, "", log.LstdFlags)

tui.SetLogger(logger)

Inspecting logs during runtime

Opening and closing your application to check the logs is time-consuming and unnecessary. Instead, open you application and run tail -f debug.log in another terminal to get immediate feedback.

Clone this wiki locally