logx

package
v0.211.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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").

func (*FileSink) Close added in v0.209.3

func (s *FileSink) Close() error

Close releases the file handle. The sink stays USABLE: lumberjack reopens the file on the next write (and re-checks the rotation size), so closing after each line is the way a component sink keeps from holding a handle it does not need.

func (*FileSink) Logger added in v0.209.3

func (s *FileSink) Logger() *slog.Logger

Logger is the sink's logger; every record it accepts lands in the file (the underlying write is synchronous, so a short-lived process loses nothing on exit).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL