logging

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package logging is part of the GoFastr harness.

See docs/harness-architecture.md § Logging.

Package logging implements the harness's own operational logs (distinct from the per-session event log in package session).

Per § Logging:

  • Structured JSON, one object per line.
  • Daily-rotated files at ~/.local/state/gofastr/harness/log/harness-YYYYMMDD.log.
  • Components: engine, multiplex, provider.<name>, transport.<name>, mcpclient, mcpserver, skill, hook, auth.
  • Per-component level via --log-level engine=debug,provider.copilot=trace.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DailyFileWriter

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

DailyFileWriter writes to a per-day file at the given directory, rotating at UTC midnight.

func NewDailyFileWriter

func NewDailyFileWriter(dir string) (*DailyFileWriter, error)

NewDailyFileWriter returns a writer that opens `<dir>/harness-YYYYMMDD.log` and rotates on day change.

func (*DailyFileWriter) Close

func (w *DailyFileWriter) Close() error

Close closes the underlying file.

func (*DailyFileWriter) Write

func (w *DailyFileWriter) Write(p []byte) (int, error)

type Level

type Level uint8

Level is the log level enum.

const (
	LevelTrace Level = iota
	LevelDebug
	LevelInfo
	LevelWarn
	LevelError
)

func ParseLevel

func ParseLevel(s string) (Level, error)

ParseLevel parses a level string.

func (Level) String

func (l Level) String() string

String returns the lowercase name.

type Logger

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

Logger writes structured JSON log lines.

func New

func New(out io.Writer, defaultLevel Level) *Logger

New returns a Logger writing to out at the given default level.

func (*Logger) ApplyOverrides

func (l *Logger) ApplyOverrides(spec string) error

ApplyOverrides parses a string like "engine=debug,provider.openrouter=trace" and updates component levels accordingly.

func (*Logger) Debug

func (l *Logger) Debug(msg string, kv ...any)

func (*Logger) Error

func (l *Logger) Error(msg string, kv ...any)

func (*Logger) Info

func (l *Logger) Info(msg string, kv ...any)

func (*Logger) Log

func (l *Logger) Log(level Level, msg string, fields map[string]any)

Log writes one structured record. Use Trace/Debug/Info/Warn/Error helpers for level-tagged shortcuts.

func (*Logger) SetComponentLevel

func (l *Logger) SetComponentLevel(component string, level Level)

SetComponentLevel overrides the level for one component.

func (*Logger) Trace

func (l *Logger) Trace(msg string, kv ...any)

Trace / Debug / Info / Warn / Error are level-tagged shortcuts.

func (*Logger) Warn

func (l *Logger) Warn(msg string, kv ...any)

func (*Logger) WithComponent

func (l *Logger) WithComponent(component string) *Logger

WithComponent returns a child Logger tagged with the given component name. Component levels override the default.

Jump to

Keyboard shortcuts

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