log

package
v0.22.9-2 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsLevel added in v0.4.8

func IsLevel(logger Logger, level Level) bool

IsLevel reports whether current logger shows logs for the given log level.

Types

type ErrorWithFields

type ErrorWithFields interface {
	error
	LogFields() Fields
}

type Fields

type Fields = map[string]any

type Level

type Level uint8
const (
	Panic Level = iota
	Error
	Warn
	Info
	Debug
)

func ParseLevel

func ParseLevel(lvl string) (Level, error)

ParseLevel takes a string level and returns the Logrus log level constant.

func (Level) String

func (l Level) String() string

type Logger

type Logger interface {
	// Level returns the current logging level.
	Level() Level

	// WithField returns a new logger instance that includes the specified
	// key-value pair.
	WithField(key string, value any) Logger

	// WithFields returns a new logger instance that includes the specified
	// key-value pairs.
	WithFields(fields Fields) Logger

	// WithError associates an error with the logger, returning a new logger
	// instance. The associated error will be included in subsequent log
	// messages.
	WithError(err error) Logger

	// WithAdvice associates a recommended action or advice with the logger,
	// detailing what steps should be taken in response to the event being
	// logged. This can be helpful to guide system administrators or developers
	// on the appropriate course of action when reading the logs.
	//
	// Examples:
	// - "Ignore if happens occasionally"
	// - "This is a known issue; a fix is in progress"
	// - "Report immediately to the development team"
	WithAdvice(advice string) Logger

	// Debug logs detailed system-level diagnostic messages useful during
	// development and troubleshooting. It should contain information that's
	// typically too verbose for regular operation.
	Debug(args ...any)

	// Info logs informational messages that highlight the progress of the
	// application's normal operation, such as startup and significant runtime
	// events. These messages should be concise but informative for system
	// administrators and should not occur at a high rate.
	Info(args ...any)

	// Warn logs potentially harmful situations, unexpected events, or minor
	// issues. This might include things like deprecations or approaching
	// resource limits. These aren't immediate errors but can lead to them if
	// unaddressed.
	Warn(args ...any)

	// Error logs failures that prevent an operation from completing
	// successfully. While the application might continue running, these issues
	// typically require intervention to resolve, either as system
	// administration or code changes.
	Error(args ...any)

	// Panic logs severe errors that might cause the application to crash or be
	// in an unstable state. Logging at this level should be rare and often
	// followed by program termination. These messages should provide enough
	// context to diagnose and rectify catastrophic failures.
	Panic(args ...any)
}

Logger defines an interface for structured logging with varying levels of severity.

type LoggerService added in v0.6.0

type LoggerService interface {
	Logger
	Start(ctx context.Context) error
	Wait() <-chan error
}

LoggerService is a logger that needs to be started to be used.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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