Documentation
¶
Index ¶
- Variables
- func Debug(args ...any)
- func Debugf(format string, args ...any)
- func Error(args ...any)
- func Errorf(format string, args ...any)
- func Fatal(args ...any)
- func Fatalf(format string, args ...any)
- func GetRequestLogger(ctx *fiber.Ctx) *zerolog.Logger
- func GetSSHRequestLogger(sessionID string) *zerolog.Logger
- func Info(args ...any)
- func Infof(format string, args ...any)
- func Init(s Settings)
- func MustGetAccessLogger() io.Writer
- func MustUpdateAccessLogger()
- func SetOutput(s Settings)
- func Warn(args ...any)
- func Warnf(format string, args ...any)
- type FieldLogger
- func (f *FieldLogger) Debug(args ...any)
- func (f *FieldLogger) Debugf(format string, args ...any)
- func (f *FieldLogger) Error(args ...any)
- func (f *FieldLogger) Errorf(format string, args ...any)
- func (f *FieldLogger) Fatal(args ...any)
- func (f *FieldLogger) Fatalf(format string, args ...any)
- func (f *FieldLogger) Info(args ...any)
- func (f *FieldLogger) Infof(format string, args ...any)
- func (f *FieldLogger) Warn(args ...any)
- func (f *FieldLogger) Warnf(format string, args ...any)
- type Fields
- type InternalLogSettings
- type LogOutputSettings
- type Settings
- type SmartSettings
Constants ¶
This section is empty.
Variables ¶
var Log = defaultLogger()
Log is the package-level zerolog.Logger used throughout OFFA. It is the single source of truth for internal logging and is configured through Init / SetOutput. It is initialised to a sane default (no-color console writer to stderr at info level) so it can be used before Init is called, e.g. during the initial config load. Call sites that need logrus-style ergonomics may use the package-level helper functions (Debug, Info, WithError, ...) below, which all operate on Log.
Functions ¶
func Debug ¶ added in v0.5.0
func Debug(args ...any)
Package-level terminal helpers (operate on Log)
func GetRequestLogger ¶
GetRequestLogger returns a *zerolog.Logger scoped to the given request id.
When smart logging is disabled (the default), the returned logger simply attaches the request id to the regular internal logger. When smart logging is enabled, the returned logger additionally buffers all entries for the request and flushes them to a dedicated per-request file the first time an error is logged for that request; if no error occurs, no per-request file is created.
func GetSSHRequestLogger ¶
GetSSHRequestLogger returns a *zerolog.Logger scoped to the given SSH session id, with the same smart-logging semantics as GetRequestLogger.
func Init ¶
func Init(s Settings)
Init initializes the logger from the given settings. It must be called after the config has been loaded and before any logging is expected.
func MustGetAccessLogger ¶
MustGetAccessLogger opens the server access logger; on failure the program exits. The returned io.Writer is suitable as the output for fiber's logger middleware and can be swapped at runtime via MustUpdateAccessLogger (e.g. on SIGHUP log file rotation).
func MustUpdateAccessLogger ¶
func MustUpdateAccessLogger()
MustUpdateAccessLogger updates the writer of the access logger, e.g. after a config reload or log rotation signal.
func SetOutput ¶
func SetOutput(s Settings)
SetOutput (re)configures the internal logger output, level, and caller reporting based on the given settings. It also routes the go-oidfed library's internal logger to the same destination and level so that library logs are emitted alongside OFFA's own logs. Safe to call on SIGHUP / config reload.
Types ¶
type FieldLogger ¶ added in v0.5.0
type FieldLogger struct {
// contains filtered or unexported fields
}
FieldLogger is a logrus.Entry-like handle carrying context (an error and/or structured fields) that is applied to every log statement produced through its terminal methods.
func WithError ¶ added in v0.5.0
func WithError(err error) *FieldLogger
WithError returns a FieldLogger that attaches the given error to all subsequent log statements, mirroring logrus.WithError.
func WithField ¶ added in v0.5.0
func WithField(key string, value any) *FieldLogger
WithField returns a FieldLogger that attaches a single structured field to all subsequent log statements, mirroring logrus.WithField.
func WithFields ¶ added in v0.5.0
func WithFields(fields Fields) *FieldLogger
WithFields returns a FieldLogger that attaches multiple structured fields to all subsequent log statements, mirroring logrus.WithFields.
func (*FieldLogger) Debug ¶ added in v0.5.0
func (f *FieldLogger) Debug(args ...any)
Terminal methods (logrus-style, variadic -> fmt.Sprint)
func (*FieldLogger) Debugf ¶ added in v0.5.0
func (f *FieldLogger) Debugf(format string, args ...any)
Formatted variants
func (*FieldLogger) Error ¶ added in v0.5.0
func (f *FieldLogger) Error(args ...any)
func (*FieldLogger) Errorf ¶ added in v0.5.0
func (f *FieldLogger) Errorf(format string, args ...any)
func (*FieldLogger) Fatal ¶ added in v0.5.0
func (f *FieldLogger) Fatal(args ...any)
func (*FieldLogger) Fatalf ¶ added in v0.5.0
func (f *FieldLogger) Fatalf(format string, args ...any)
func (*FieldLogger) Info ¶ added in v0.5.0
func (f *FieldLogger) Info(args ...any)
func (*FieldLogger) Infof ¶ added in v0.5.0
func (f *FieldLogger) Infof(format string, args ...any)
func (*FieldLogger) Warn ¶ added in v0.5.0
func (f *FieldLogger) Warn(args ...any)
func (*FieldLogger) Warnf ¶ added in v0.5.0
func (f *FieldLogger) Warnf(format string, args ...any)
type Fields ¶ added in v0.5.0
Fields is the field-map type used by WithFields, mirroring logrus.Fields.
type InternalLogSettings ¶ added in v0.5.0
type InternalLogSettings struct {
LogOutputSettings
Level string
Smart SmartSettings
}
InternalLogSettings describes the internal logger configuration.
type LogOutputSettings ¶ added in v0.5.0
LogOutputSettings describes a log destination: optionally a directory holding a log file and/or stderr. It mirrors config.LoggerConf but lives here so that this package does not depend on the config package (which would create an import cycle, as config uses this package for its own logging).
type Settings ¶ added in v0.5.0
type Settings struct {
Access LogOutputSettings
Internal InternalLogSettings
}
Settings holds the logger configuration passed in from the application (built from config.Config.Logging) via Init / SetOutput.
func ActiveSettings ¶ added in v0.5.0
func ActiveSettings() Settings
Settings returns the currently active logger settings.
type SmartSettings ¶ added in v0.5.0
SmartSettings configures the per-request "smart" logger.