Skip to content

Logger

The Tako framework provides a built-in logging interface defined in contracts.Logger. It ensures all plugins and core systems log messages in a unified, consistent format.

The Logger Contract

The interface is simple and leveled:

go
// contracts/logger.go
type Logger interface {
    Debug(msg string, args ...any)
    Info(msg string, args ...any)
    Warn(msg string, args ...any)
    Error(msg string, args ...any)
    Fatal(msg string, args ...any)
}

The args parameter uses key-value pairs (alternating string keys and arbitrary values) similar to log/slog in Go 1.21+.

Using the Logger in a Plugin

The easiest way to get the logger is via the tako.Context object inside your plugin lifecycle methods:

go
func (p *Plugin) OnInit(ctx *tako.Context) error {
    logger := ctx.Logger()
    
    logger.Info("search plugin initialized", 
        "version", "1.0",
        "dependencies_met", true,
    )
    
    return nil
}

Where Do Logs Go?

By default, Tako applications redirect their standard output when rendering the TUI, which means you cannot use fmt.Println to debug—it will break the terminal rendering.

Instead, the framework logger automatically writes to a file:

  • Default Location: .tako/tako.log inside your application directory.
  • Log Format: Text format or JSON (depending on environment/configuration).

You can easily trail this log while your TUI is running using a separate terminal tab:

bash
tail -f .tako/tako.log

Advanced: Replacing the Default Logger

Tako uses its own default implementation of the logger, but because it relies on the Service Container, you can override it with your own logger (e.g., configuring slog, logrus, or zap to output structured JSON) before calling tako.Run(app).

go
app := tako.NewApp()

// Overwrite the default Logger implementation
app.Container().Singleton(new(contracts.Logger), myCustomLoggerInstance)

tako.Run(app)

Up next: That covers the Core Concepts. Proceed to 04 — Layer Management to understand how Tako handles rendering overlays and UI components automatically.