log

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LevelDebug = slog.LevelDebug
	LevelInfo  = slog.LevelInfo
	LevelWarn  = slog.LevelWarn
	LevelError = slog.LevelError
)

Log levels.

Variables

View Source
var (
	String   = slog.String
	Int      = slog.Int
	Int64    = slog.Int64
	Uint64   = slog.Uint64
	Float64  = slog.Float64
	Bool     = slog.Bool
	Time     = slog.Time
	Duration = slog.Duration
	Group    = slog.Group
	Any      = slog.Any
)

Re-export slog attribute constructors so callers don't need to import log/slog

Functions

func LogPath added in v1.11.0

func LogPath(env string) (string, error)

LogPath returns the log file path for the given environment.

Types

type Level

type Level = slog.Level

Level re-exports slog.Level for callers.

type Logger

type Logger interface {
	Debug(msg string, args ...any)
	Info(msg string, args ...any)
	Warn(msg string, args ...any)
	Error(msg string, args ...any)
	With(args ...any) Logger
}

Logger is the interface for logging throughout the application

func New

func New(env string, level Level) Logger

New creates a new logger that writes to ~/.tero/environments/{env}/tero.log. Appends to existing log file, with a clear session separator. Truncates the file at session start if it exceeds 5MB. Falls back to a no-op logger if the log file cannot be opened.

func Wrap

func Wrap(l *slog.Logger) Logger

Wrap wraps a *slog.Logger to implement the Logger interface.

type Scope

type Scope struct {
	// contains filtered or unexported fields
}

Scope wraps a Logger with hierarchical path tracking. Pass scopes down through component constructors to build a hierarchy of nested components. Unlike OpenTelemetry spans, scopes are long-lived (component lifetime) not per-operation.

func RootScope

func RootScope(logger Logger) Scope

RootScope creates a root scope from a logger. It has no name until Child is called.

func (Scope) Child

func (s Scope) Child(name string) Scope

Child creates a child scope with the given name appended to the path.

func (Scope) Debug

func (s Scope) Debug(msg string, args ...any)

Debug logs at debug level.

func (Scope) Error

func (s Scope) Error(msg string, args ...any)

Error logs at error level.

func (Scope) Info

func (s Scope) Info(msg string, args ...any)

Info logs at info level.

func (Scope) Path

func (s Scope) Path() string

Path returns the full scope path.

func (Scope) Warn

func (s Scope) Warn(msg string, args ...any)

Warn logs at warn level.

func (Scope) With

func (s Scope) With(args ...any) Scope

With returns a new scope with additional context.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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