logging

package
v0.0.0-...-b235061 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnsupportedLoggerKind is returned when an unsupported logger Kind is specified.
	ErrUnsupportedLoggerKind = errors.New("unsupported logger kind")
	// ErrInvalidLogLevel is returned when an invalid log level is specified.
	ErrInvalidLogLevel = errors.New("invalid log level")
	// ErrInvalidLogger is returned when an invalid logger is specified.
	ErrInvalidLogger = errors.New("invalid logger")
	// ErrLoggingConfigNotFound is returned when a logging config is not found.
	ErrLoggingConfigNotFound = errors.New("logging config not found")
)

Functions

func ProvideLogger

func ProvideLogger(config interfaces.Config) (interfaces.Logger, error)

Types

type LoggerFactory

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

func NewLoggerFactory

func NewLoggerFactory(config interfaces.Config) (*LoggerFactory, error)

NewLoggerFactory creates a new instance of LoggerFactory.

func (*LoggerFactory) GetLogger

func (b *LoggerFactory) GetLogger() (interfaces.Logger, error)

GetLogger provides a logger based on the configuration.

func (*LoggerFactory) GetLoggerConfig

func (b *LoggerFactory) GetLoggerConfig() interfaces.LoggingConfig

type LoggingConfig

type LoggingConfig struct {
	// Level is the logging level.
	Level constants.Level `mapstructure:"level" json:"level"`
	// Kind is the logger Kind.
	LoggerKind constants.LoggerKind `mapstructure:"kind" json:"kind"`
}

LoggingConfig represents the logging configuration.

func (*LoggingConfig) GetLevel

func (l *LoggingConfig) GetLevel() constants.Level

GetLevel returns the logging level.

func (*LoggingConfig) GetLoggerKind

func (l *LoggingConfig) GetLoggerKind() constants.LoggerKind

GetLoggerKind returns the logger Kind.

type LogrusLogger

type LogrusLogger struct {
	Logger *logrus.Logger
}

LogrusLogger is a logger implementation using logrus.

func NewLogrusLogger

func NewLogrusLogger(config interfaces.LoggingConfig) *LogrusLogger

NewLogrusLogger creates a new instance of LogrusLogger.

func (*LogrusLogger) Debug

func (l *LogrusLogger) Debug(msg string)

Debug logs a message at the debug level.

func (*LogrusLogger) Debugf

func (l *LogrusLogger) Debugf(format string, args ...interface{})

Debugf logs a formatted message at the debug level.

func (*LogrusLogger) Error

func (l *LogrusLogger) Error(msg string)

Error logs a message at the error level.

func (*LogrusLogger) Errorf

func (l *LogrusLogger) Errorf(format string, args ...interface{})

Errorf logs a formatted message at the error level.

func (*LogrusLogger) Fatal

func (l *LogrusLogger) Fatal(msg string)

Fatal logs a message at the fatal level.

func (*LogrusLogger) Fatalf

func (l *LogrusLogger) Fatalf(format string, args ...interface{})

Fatalf logs a formatted message at the fatal level.

func (*LogrusLogger) GetLevel

func (l *LogrusLogger) GetLevel() constants.Level

GetLevel returns the logging level.

func (*LogrusLogger) GetLoggerKind

func (l *LogrusLogger) GetLoggerKind() constants.LoggerKind

GetLoggerKind returns the logger Kind.

func (*LogrusLogger) Info

func (l *LogrusLogger) Info(msg string)

Info logs a message at the info level.

func (*LogrusLogger) Infof

func (l *LogrusLogger) Infof(format string, args ...interface{})

Infof logs a formatted message at the info level.

func (*LogrusLogger) SetLevel

func (l *LogrusLogger) SetLevel(level constants.Level)

SetLevel sets the logging level.

func (*LogrusLogger) Warn

func (l *LogrusLogger) Warn(msg string)

Warn logs a message at the warn level.

func (*LogrusLogger) Warnf

func (l *LogrusLogger) Warnf(format string, args ...interface{})

Warnf logs a formatted message at the warn level.

type SlogLogger

type SlogLogger struct {
	Logger *slog.Logger
	Level  slog.Level
}

SlogLogger is a logger that logs to slog.

func NewSlogLogger

func NewSlogLogger(config interfaces.LoggingConfig) *SlogLogger

NewSlogLogger creates a new SlogLogger.

func (*SlogLogger) Debug

func (l *SlogLogger) Debug(msg string)

Debug logs a message at the debug level.

func (*SlogLogger) Debugf

func (l *SlogLogger) Debugf(format string, args ...any)

Debugf logs a formatted message at the debug level.

func (*SlogLogger) Error

func (l *SlogLogger) Error(msg string)

Error logs a message at the error level.

func (*SlogLogger) Errorf

func (l *SlogLogger) Errorf(format string, args ...any)

Errorf logs a formatted message at the error level.

func (*SlogLogger) Fatal

func (l *SlogLogger) Fatal(msg string)

Fatal logs a message at the fatal level.

func (*SlogLogger) Fatalf

func (l *SlogLogger) Fatalf(format string, args ...any)

Fatalf logs a formatted message at the fatal level.

func (*SlogLogger) GetLevel

func (l *SlogLogger) GetLevel() constants.Level

GetLevel returns the logging level.

func (*SlogLogger) GetLoggerKind

func (l *SlogLogger) GetLoggerKind() constants.LoggerKind

GetLoggerKind returns the logger Kind.

func (*SlogLogger) Info

func (l *SlogLogger) Info(msg string)

Info logs a message at the info level.

func (*SlogLogger) Infof

func (l *SlogLogger) Infof(format string, args ...any)

Infof logs a formatted message at the info level.

func (*SlogLogger) SetLevel

func (l *SlogLogger) SetLevel(level constants.Level)

SetLevel sets the logging level.

func (*SlogLogger) Warn

func (l *SlogLogger) Warn(msg string)

Warn logs a message at the warn level.

func (*SlogLogger) Warnf

func (l *SlogLogger) Warnf(format string, args ...any)

Warnf logs a formatted message at the warn level.

Jump to

Keyboard shortcuts

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