Documentation
¶
Overview ¶
Package logx configures the process-wide structured logger (slog) for gofer. A single text handler on stderr is installed as the slog default so any package can log key lifecycle events via slog.Info/Warn/Error without threading a logger through every struct. stderr (not stdout) keeps logs out of the CLI's data output (job JSON, completion scripts, etc.).
Index ¶
Constants ¶
const TimeLayout = "2006-01-02T15:04:05.000"
TimeLayout is the log timestamp format. It drops slog's default RFC3339 zone offset (the trailing "+08:00") — local time with millis is enough and far shorter to scan: 2026-06-27T15:09:21.473. It is exported so a value written INTO a log line (a deadline, an expected wake time) is formatted like the line's own timestamp and can be read as a time, not as a unix number.
Variables ¶
This section is empty.
Functions ¶
func ConfigureFile ¶
func ConfigureFile(o FileOptions) error
ConfigureFile adds a rotating JSONL sink while retaining the text stderr sink. Explicit paths fail startup when they cannot be opened; implicit defaults warn and continue with stderr only.
func Setup ¶
func Setup()
Setup installs the default slog logger. The level comes from GOFER_LOG_LEVEL (debug | info | warn | error; default info); an unrecognised value falls back to info. Called once at process start (cmd/gofer/main).
func SilenceStderr ¶
func SilenceStderr()
SilenceStderr drops the stderr text sink for the rest of the process: a later ConfigureFile keeps only its file sink, and until then the default logger discards everything. It is what `gofer tunnel forward --quiet` means: nothing on the terminal, the file log untouched.
Types ¶
type FileOptions ¶
type FileOptions struct {
Path string
MaxSizeMB, MaxAgeDays, MaxBackups int
Explicit bool
Component string
}
FileOptions describes a rotating JSONL sink for one process component.
type FileSink ¶ added in v0.209.3
type FileSink struct {
// contains filtered or unexported fields
}
FileSink is a standalone rotating JSONL sink: a logger that writes only to its own file. Unlike ConfigureFile it installs NOTHING globally — the process default logger (usually the stderr text handler) is left exactly as it was, so adding a component log can never change a command's stdout/stderr contract. Rotation, redaction, time layout and the level (GOFER_LOG_LEVEL) are the same as ConfigureFile's file sink.
A sink is meant to be closed after a batch of records (the client request log closes after every line): writes are synchronous, so nothing is lost, and a component log never keeps a handle on the user's file — or on a temp config dir in a test — between lines.
func OpenFileSink ¶ added in v0.209.3
func OpenFileSink(o FileOptions) (*FileSink, error)
OpenFileSink opens the rotating JSONL file o.Path and returns a sink writing to it only. It fails when the path cannot be created — the caller decides whether that is fatal (the client's request log treats it as "log disabled").