log

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2024 License: MIT Imports: 10 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Formatter

type Formatter interface {
	// Format formats the log payload that will be rendered.
	Format(context.Context, *format.LogInput) any
}

Formatter defines how structures that formats logs should behavior.

type Level

type Level int

Level indicates the severity of the data being logged.

const (
	// LevelCritical alerts about severe problems. Most of the time, needs some human intervention ASAP.
	LevelCritical Level = iota + 1
	// LevelError alerts about events that are likely to cause problems.
	LevelError
	// LevelWarning warns about events the might cause problems to the system.
	LevelWarning
	// LevelInfo are routine information.
	LevelInfo
	// LevelDebug are debug or trace information.
	LevelDebug
)

func (Level) String

func (l Level) String() string

String returns the name of the LogLevel.

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger is the structure responsible for log data.

func NewLogger

func NewLogger(opts ...Option) *Logger

NewLogger constructs a new Logger instance.

func (Logger) Critical

func (l Logger) Critical(ctx context.Context, err error, args ...any)

Critical logs critical data.

func (Logger) Debug

func (l Logger) Debug(ctx context.Context, msg string, args ...any)

Debug logs debug data.

func (Logger) Error

func (l Logger) Error(ctx context.Context, err error, args ...any)

Error logs error data.

func (Logger) Fatal

func (l Logger) Fatal(ctx context.Context, err error, args ...any)

Fatal logs critical data and exists current program execution.

func (Logger) Info

func (l Logger) Info(ctx context.Context, msg string, args ...any)

Info logs info data.

func (Logger) Warning

func (l Logger) Warning(ctx context.Context, msg string, args ...any)

Warning logs warning data.

type Option added in v1.1.0

type Option func(*Logger)

Option is a type to set Logger options.

func WithContextKeySet added in v1.1.0

func WithContextKeySet(keys propagation.ContextKeySet) Option

WithContextKeySet instructs the Logger to include the given context keys in logs.

func WithFormatter added in v1.1.0

func WithFormatter(formatter Formatter) Option

WithFormatter instructs the Logger to use the given formatter for logging.

func WithLevel added in v1.1.0

func WithLevel(level string) Option

WithLevel instructs the Logger to use the given log level.

func WithTimmer added in v1.1.0

func WithTimmer(now func() time.Time) Option

WithTimmer instructs the Logger to use the given timmer to get current Time for logging. It must be used just for testing.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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