log

package
v0.0.0-...-420f0b0 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ZapLevelFromString

func ZapLevelFromString(s string) (zapcore.Level, error)

Types

type AccessLogConfig

type AccessLogConfig struct {
	// Level is the record log level for audit log entries. Either 'debug',
	// 'info', 'warn' or 'error'.
	Level string `json:"level" yaml:"level"`

	RequestHeaders AccessLogHeaderConfig `json:"request_headers" yaml:"request_headers"`

	ResponseHeaders AccessLogHeaderConfig `json:"response_headers" yaml:"response_headers"`

	// Disable disables the access log, so requests will not be logged.
	Disable bool `json:"disable" yaml:"disable"`
}

func (*AccessLogConfig) RegisterFlags

func (c *AccessLogConfig) RegisterFlags(fs *pflag.FlagSet, prefix string)

func (*AccessLogConfig) Validate

func (c *AccessLogConfig) Validate() error

type AccessLogHeaderConfig

type AccessLogHeaderConfig struct {
	// BlockList contains headers that will be redacted from the audit log.
	//
	// You must only define one of AllowList or BlockList.
	BlockList []string `json:"block_list" yaml:"block_list"`

	// AllowList contains the ONLY headers that will be logged.
	//
	// You must only define one of AllowList or BlockList.
	AllowList []string `json:"allow_list" yaml:"allow_list"`
}

func (*AccessLogHeaderConfig) RegisterFlags

func (c *AccessLogHeaderConfig) RegisterFlags(fs *pflag.FlagSet, prefix string)

func (*AccessLogHeaderConfig) Validate

func (c *AccessLogHeaderConfig) Validate() error

type Config

type Config struct {
	// Level is the minimum record level to log. Either 'debug', 'info', 'warn'
	// or 'error'.
	Level string `json:"level" yaml:"level"`

	// Subsystems enables debug logging on log records whose 'subsystem'
	// matches one of the given values (overrides `Level`).
	Subsystems []string `json:"subsystems" yaml:"subsystems"`
}

func (*Config) RegisterFlags

func (c *Config) RegisterFlags(fs *pflag.FlagSet)

func (*Config) Validate

func (c *Config) Validate() error

type Logger

type Logger interface {
	Subsystem() string
	// WithSubsystem creates a new logger with the given subsystem.
	WithSubsystem(s string) Logger
	With(fields ...zap.Field) Logger
	Debug(msg string, fields ...zap.Field)
	Info(msg string, fields ...zap.Field)
	Warn(msg string, fields ...zap.Field)
	Error(msg string, fields ...zap.Field)
	Log(level zapcore.Level, msg string, fields ...zap.Field)
	Sync() error
	// StdLogger returns a standard library log.Logger that logs records using
	// with the given level.
	StdLogger(level zapcore.Level) *stdlog.Logger
}

Logger is a logger which writes structured logs to stderr formatted as JSON.

Logs can be filtered by level, where only logs whose level exceeds the configured minimum level are logged. The log level can be overridden to include all logs matching the enabled subsystems.

Logger is a simplified zap.Logger (which uses zapcore). zap.Logger had to be reimplemented to support overriding the log level filter.

func NewLogger

func NewLogger(lvl string, enabledSubsystems []string) (Logger, error)

NewLogger creates a new logger filtering using the given log level and enabled subsystems.

func NewNopLogger

func NewNopLogger() Logger

Jump to

Keyboard shortcuts

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