Documentation
¶
Overview ¶
Package logrus provides a slog.Logger using github.com/sirupsen/logrus Logger as backend
Index ¶
- Constants
- func New(logger *logrus.Logger) slog.Logger
- func NewLogrusLogger(slogLogger slog.Logger) *logrus.Logger
- func SetupLogrusToSlog(logrusLogger *logrus.Logger, slogLogger slog.Logger)
- type Logger
- func (rl *Logger) Debug() slog.Logger
- func (rl *Logger) Enabled() bool
- func (rl *Logger) Error() slog.Logger
- func (rl *Logger) Fatal() slog.Logger
- func (rl *Logger) Info() slog.Logger
- func (rl *Logger) Level() slog.LogLevel
- func (rl *Logger) Panic() slog.Logger
- func (rl *Logger) Print(args ...any)
- func (rl *Logger) Printf(format string, args ...any)
- func (rl *Logger) Println(args ...any)
- func (rl *Logger) Warn() slog.Logger
- func (rl *Logger) WithEnabled() (slog.Logger, bool)
- func (rl *Logger) WithField(label string, value any) slog.Logger
- func (rl *Logger) WithFields(fields map[string]any) slog.Logger
- func (rl *Logger) WithLevel(level slog.LogLevel) slog.Logger
- func (rl *Logger) WithStack(skip int) slog.Logger
- type SlogHook
Constants ¶
View Source
const ( // CallerFieldName is the field name to be used by WithStack() // attempting to mimic the effect of logrus' own SetReportCaller() CallerFieldName = "method" // StackFieldName is the field name used to store the formatted callstack StackFieldName = "call-stack" )
Variables ¶
This section is empty.
Functions ¶
func NewLogrusLogger ¶ added in v0.7.2
NewLogrusLogger creates a new logrus.Logger that outputs to slog
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is an adaptor for using github.com/sirupsen/logrus as slog.Logger
func (*Logger) Level ¶ added in v0.7.3
Level returns the current log level. Exposed for testing only.
func (*Logger) Println ¶
Println adds a log entry with arguments handled in the manner of fmt.Println
func (*Logger) WithEnabled ¶
WithEnabled tells if the logger would log or not
func (*Logger) WithFields ¶
WithFields adds fields to the log entry
type SlogHook ¶ added in v0.7.2
type SlogHook struct {
// contains filtered or unexported fields
}
SlogHook is a logrus hook that forwards all log entries to a slog.Logger
func NewSlogHook ¶ added in v0.7.2
NewSlogHook creates a logrus Hook that forwards to slog
Click to show internal directories.
Click to hide internal directories.