logger

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(cfg Config) (*slog.Logger, error)

New constructs a *slog.Logger. Writer resolution priority:

  1. cfg.Output (explicit override — useful for tests)
  2. file in cfg.LogDir named "{agentId}+{timestamp}.log"
  3. os.Stdout

func OfAgent

func OfAgent(cfg *config.Config, parentID, agentID string) (*slog.Logger, error)

OfAgent constructs a logger using the supplied runtime configuration. cfg may be nil — the logger falls back to stdout in that case (useful for tests).

Types

type Config

type Config struct {
	Level   string
	Format  string
	AgentID string    // required: identifies the agent, used in log filename
	LogDir  string    // optional: if empty, falls back to os.Stdout
	Output  io.Writer // optional: override resolved writer (useful in tests)
}

Config holds logger configuration. Output is optional — resolved at construction time based on LogDir + AgentID.

Jump to

Keyboard shortcuts

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