log

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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)
	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