logger

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 26, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package logger provides opinionated logging capabilities for the tapes system.

It builds on Go's log/slog, with pluggable handlers for pretty CLI output (via charmbracelet/log) and structured JSON for services. All public constructors return *slog.Logger directly — no custom interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Multi

func Multi(loggers ...*slog.Logger) *slog.Logger

Multi creates a *slog.Logger that dispatches every record to all provided loggers' underlying handlers. Each logger's handler is extracted via (*slog.Logger).Handler().

func New

func New(opts ...Option) *slog.Logger

New creates a *slog.Logger configured by the given options.

Defaults: Info level, writes to os.Stdout, slog.TextHandler.

func NewNoop

func NewNoop() *slog.Logger

NewNoop returns a *slog.Logger that discards all output. Useful for tests.

Types

type Option

type Option func(*config)

Option configures a Logger created with New.

func WithDebug

func WithDebug(debug bool) Option

WithDebug sets the log level to Debug when true, Info otherwise.

func WithJSON

func WithJSON(json bool) Option

WithJSON enables slog's JSON handler for structured service logs.

func WithPretty

func WithPretty(pretty bool) Option

WithPretty enables the charmbracelet/log handler for colorized, human-friendly CLI output.

func WithSource

func WithSource(source bool) Option

WithSource includes source file:line in log output.

func WithWriter

func WithWriter(w io.Writer) Option

WithWriter overrides the output writer. Defaults to os.Stdout.

func WithWriters

func WithWriters(w ...io.Writer) Option

WithWriters sets multiple output writers (combined via io.MultiWriter).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL