Documentation
¶
Overview ¶
Package applog provides logging for cliamp.
Two sinks are layered behind one API:
- A file sink, written through log/slog, for diagnostic logs the user reads after the fact (~/.config/cliamp/cliamp.log).
- An in-memory ring buffer drained by the TUI footer for short-lived, user-facing messages. The buffer exists because writing to stderr would corrupt the TUI.
Callers pick by intent, not sink:
- Debug/Info/Warn/Error write only to the file.
- Status writes only to the footer (transient UI feedback that wouldn't help post-mortem debugging).
- UserWarn/UserError write to both.
Init must be called once at startup. Calls before Init are silently dropped on the file side; the footer buffer always works.
Index ¶
- Constants
- func Debug(format string, args ...any)
- func Error(format string, args ...any)
- func Info(format string, args ...any)
- func Init(path string, level Level) (func() error, error)
- func Status(format string, args ...any)
- func UserError(format string, args ...any)
- func UserWarn(format string, args ...any)
- func Warn(format string, args ...any)
- type Entry
- type Level
Constants ¶
const ( LevelDebug = slog.LevelDebug LevelInfo = slog.LevelInfo LevelWarn = slog.LevelWarn LevelError = slog.LevelError )
Variables ¶
This section is empty.
Functions ¶
func Debug ¶
Debug, Info, Warn, Error log only to the file. Format follows fmt.Sprintf. The level guard avoids paying the Sprintf cost when the level is filtered out.
func Init ¶
Init opens path for append, installs a slog text handler at the given level, and returns a close func. Calling Init twice closes the previous file before swapping handlers.
func Status ¶
Status pushes a message into the footer buffer without writing to the log file. Use for ephemeral, user-facing notifications that wouldn't help post-mortem debugging.