Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New constructs a *slog.Logger. Writer resolution priority:
- cfg.Output (explicit override — useful for tests)
- file in cfg.LogDir named "{agentId}+{timestamp}.log"
- os.Stdout
The returned io.Closer owns the log file when New opened one (nil otherwise) — the agent must Close it on shutdown. Leaving it open merely leaked an fd on unix, but on Windows an open log file blocks deletion of its directory (TempDir cleanup, space removal, rotation).
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.
Click to show internal directories.
Click to hide internal directories.