Help us shape the future of Go! Take the 2026 Go Developer Survey

logger

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: Apache-2.0 Imports: 4 Imported by: 63

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsLevel

func IsLevel(l Level, levels ...Level) bool

func IsVerbose

func IsVerbose(level Level) bool

Types

type Controller

type Controller interface {
	SetOutput(io.Writer)
	GetOutput() io.Writer
}

type DebugMessageLogger

type DebugMessageLogger interface {
	Debugf(format string, args ...any)
	Debug(args ...any)
}

type ErrorMessageLogger

type ErrorMessageLogger interface {
	Errorf(format string, args ...any)
	Error(args ...any)
}

type FieldLogger

type FieldLogger interface {
	WithFields(fields ...any) MessageLogger
}

type Fields

type Fields map[string]any

type InfoMessageLogger

type InfoMessageLogger interface {
	Infof(format string, args ...any)
	Info(args ...any)
}

type Level

type Level string
const (
	DisabledLevel Level = ""
	ErrorLevel    Level = "error"
	WarnLevel     Level = "warn"
	InfoLevel     Level = "info"
	DebugLevel    Level = "debug"
	TraceLevel    Level = "trace"
)

func LevelFromString

func LevelFromString(l string) (Level, error)

func LevelFromVerbosity

func LevelFromVerbosity(v int, levels ...Level) Level

func Levels

func Levels() []Level

type Logger

type Logger interface {
	MessageLogger
	FieldLogger
	NestedLogger
}

type NestedLogger

type NestedLogger interface {
	Nested(fields ...any) Logger
}

type TerminalWriter added in v0.2.0

type TerminalWriter interface {
	io.Writer
	IsTerminal() bool
}

TerminalWriter is an output that is not a terminal file itself but whose contents are ultimately rendered to one (e.g. a buffer drawn by a TUI). Formatters use this to decide on terminal-only styling, such as colors.

IsTerminal is called for every entry while the logger holds its lock, so it must be cheap, safe for concurrent use, and must never log (doing so will deadlock). Only implement this when everything written ends up on a terminal; a tee that also writes to a file would get ANSI codes in that file. Wrappers such as io.MultiWriter and bufio.Writer do not forward IsTerminal, so wrapping a TerminalWriter drops the signal.

type TraceMessageLogger

type TraceMessageLogger interface {
	Tracef(format string, args ...any)
	Trace(args ...any)
}

type WarnMessageLogger

type WarnMessageLogger interface {
	Warnf(format string, args ...any)
	Warn(args ...any)
}

Directories

Path Synopsis
adapter
charm module

Jump to

Keyboard shortcuts

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