Documentation
¶
Overview ¶
Package logging is instigator's leveled log output: ERROR/WARN/INFO/ DEBUG lines with ISO8601 timestamps, built on log/slog. It exists because the flat, single-level log this project started with hid a real bug: an rsh command instcmd refused ("fgrep: not supported") went only to the client's own stderr, never to our side, so serve.log stayed silent about it through a live install failure. A refusal now has a level - ERROR - that's visible in the server's own log by default, not something a client can swallow.
Every existing call site across bootp/tftp/rcmd/instcmd/serve already builds a formatted message with fmt-style verbs; Logger keeps that shape (Debugf/Infof/Warnf/Errorf) rather than moving every call site to slog's structured key-value API, which would be a much bigger change for no benefit here - nothing in this project queries its own logs as structured data.
Index ¶
Constants ¶
const ( LevelDebug = slog.LevelDebug // per-packet/per-block decode detail, -v only LevelInfo = slog.LevelInfo // normal serving: requests answered, transfers made LevelWarn = slog.LevelWarn // a request refused or malformed on the client's end LevelError = slog.LevelError // this side failed to do something it should have )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger provides leveled, printf-style logging to one destination. The zero value is not usable; use New. A nil *Logger is safe to call (every method is a no-op), matching the old Logf-unset-means-silent convention every caller and test already relies on.
func New ¶
New builds a Logger writing one line per record to w: an ISO8601 timestamp (RFC3339 with the local zone offset, e.g. 2026-08-16T16:07:38-07:00), the level, then the formatted message. min is the lowest level actually written; records below it cost nothing beyond a level comparison, since Debugf/Infof/etc. check it before formatting their arguments.