Documentation
¶
Overview ¶
Package devlog wires slog.Default() based on the build channel and the resolved log level.
In dev: writes to <CacheDir>/debug.log at DEBUG or higher (depending on Options.Level).
In release: writes to <CacheDir>/ccpulse.log at INFO or higher (depending on Options.Level). Set Options.Level to LevelOff to disable logging entirely; no file is opened and slog.Default() is set to a discard handler.
External rotation: this package does not rotate logs. Users who want bounded log size should rotate the log file externally (e.g. logrotate). Because the file is held open for append, external mv/rm will not take effect for the running ccpulse — restart to pick up the new inode.
Init is best-effort: on any failure (mkdir or open) it sets slog.Default to the discard handler before returning the error, so callers can ignore the error and the binary keeps running quietly.
Index ¶
Constants ¶
const LevelOff slog.Level = slog.LevelError + 4
LevelOff is a sentinel slog.Level above every real level. Init treats it specially: no file is opened, slog.Default() is set to a discard handler. Mapped to LevelError + 4 so future custom levels between Error and Off remain expressible without renumbering.
Variables ¶
This section is empty.
Functions ¶
func Init ¶
Init configures slog.Default() per opts. Returns the opened log file (caller may close on shutdown) when a file is opened, or nil when no file is needed (Level == LevelOff).
Init is best-effort: on any failure path slog.Default is set to the discard handler so the binary keeps running quietly even if logging could not be set up.