Documentation
¶
Overview ¶
Implements the most important Logrus package functions as a proxy that forwards records to log/slog. Not meant for long-term use, but for easy migration to slog.
Index ¶
- Variables
- func Debug(args ...any)
- func Debugf(format string, args ...any)
- func Debugln(args ...any)
- func Error(args ...any)
- func Errorf(format string, args ...any)
- func Errorln(args ...any)
- func Fatal(args ...any)
- func Fatalf(format string, args ...any)
- func Fatalln(args ...any)
- func Info(args ...any)
- func Infof(format string, args ...any)
- func Infoln(args ...any)
- func Panic(args ...any)
- func Panicf(format string, args ...any)
- func Panicln(args ...any)
- func Print(args ...any)
- func Printf(format string, args ...any)
- func Println(args ...any)
- func SetDefault(p *Proxy)
- func SetLevel(level Level)
- func Trace(args ...any)
- func Tracef(format string, args ...any)
- func Traceln(args ...any)
- func Warn(args ...any)
- func Warnf(format string, args ...any)
- func Warning(args ...any)
- func Warningf(format string, args ...any)
- func Warningln(args ...any)
- func Warnln(args ...any)
- type FieldLogger
- type Fields
- type Level
- type Logger
- type Options
- type Proxy
- func Default() *Proxy
- func NewDiscardProxy() *Proxy
- func NewEntry(fl FieldLogger) *Proxy
- func NewProxy() *Proxy
- func NewProxyFor(logger *slog.Logger, options Options) *Proxy
- func StandardLogger() *Proxy
- func WithContext(ctx context.Context) *Proxy
- func WithError(err error) *Proxy
- func WithField(key string, value any) *Proxy
- func WithFields(fields Fields) *Proxy
- func (p *Proxy) Debug(args ...any)
- func (p *Proxy) Debugf(format string, args ...any)
- func (p *Proxy) Debugln(args ...any)
- func (p *Proxy) Error(args ...any)
- func (p *Proxy) Errorf(format string, args ...any)
- func (p *Proxy) Errorln(args ...any)
- func (p *Proxy) Fatal(args ...any)
- func (p *Proxy) Fatalf(format string, args ...any)
- func (p *Proxy) Fatalln(args ...any)
- func (p *Proxy) GetLevel() Level
- func (p *Proxy) Info(args ...any)
- func (p *Proxy) Infof(format string, args ...any)
- func (p *Proxy) Infoln(args ...any)
- func (p *Proxy) Panic(args ...any)
- func (p *Proxy) Panicf(format string, args ...any)
- func (p *Proxy) Panicln(args ...any)
- func (p *Proxy) Print(args ...any)
- func (p *Proxy) Printf(format string, args ...any)
- func (p *Proxy) Println(args ...any)
- func (p *Proxy) SetLevel(level Level)
- func (p *Proxy) Trace(args ...any)
- func (p *Proxy) Tracef(format string, args ...any)
- func (p *Proxy) Traceln(args ...any)
- func (p *Proxy) Warn(args ...any)
- func (p *Proxy) Warnf(format string, args ...any)
- func (p *Proxy) Warning(args ...any)
- func (p *Proxy) Warningf(format string, args ...any)
- func (p *Proxy) Warningln(args ...any)
- func (p *Proxy) Warnln(args ...any)
- func (p *Proxy) WithContext(ctx context.Context) *Proxy
- func (p *Proxy) WithError(err error) *Proxy
- func (p *Proxy) WithField(key string, value any) *Proxy
- func (p *Proxy) WithFields(fields Fields) *Proxy
- type StdLogger
Constants ¶
This section is empty.
Variables ¶
var AllLevels = []Level{ PanicLevel, FatalLevel, ErrorLevel, WarnLevel, InfoLevel, DebugLevel, TraceLevel, }
Functions ¶
func SetDefault ¶
func SetDefault(p *Proxy)
Types ¶
type FieldLogger ¶
type FieldLogger interface { WithField(key string, value interface{}) *Proxy WithFields(fields Fields) *Proxy WithError(err error) *Proxy Debugf(format string, args ...interface{}) Infof(format string, args ...interface{}) Printf(format string, args ...interface{}) Warnf(format string, args ...interface{}) Warningf(format string, args ...interface{}) Errorf(format string, args ...interface{}) Fatalf(format string, args ...interface{}) Panicf(format string, args ...interface{}) Debug(args ...interface{}) Info(args ...interface{}) Print(args ...interface{}) Warn(args ...interface{}) Warning(args ...interface{}) Error(args ...interface{}) Fatal(args ...interface{}) Panic(args ...interface{}) Debugln(args ...interface{}) Infoln(args ...interface{}) Println(args ...interface{}) Warnln(args ...interface{}) Warningln(args ...interface{}) Errorln(args ...interface{}) Fatalln(args ...interface{}) Panicln(args ...interface{}) Tracef(format string, args ...interface{}) Trace(args ...interface{}) Traceln(args ...interface{}) }
type Level ¶
type Level uint32
Level type
const ( // PanicLevel level, highest level of severity. Logs and then calls panic with the // message passed to Debug, Info, ... PanicLevel Level = iota // FatalLevel level. Logs and then calls `logger.Exit(1)`. It will exit even if the // logging level is set to Panic. FatalLevel // ErrorLevel level. Logs. Used for errors that should definitely be noted. // Commonly used for hooks to send errors to an error tracking service. ErrorLevel // WarnLevel level. Non-critical entries that deserve eyes. WarnLevel // InfoLevel level. General operational entries about what's going on inside the // application. InfoLevel // DebugLevel level. Usually only enabled when debugging. Very verbose logging. DebugLevel // TraceLevel level. Designates finer-grained informational events than the Debug. TraceLevel )
func ParseLevel ¶
func (Level) MarshalText ¶
func (*Level) UnmarshalText ¶
type Logger ¶
type Logger interface { WithField(key string, value interface{}) *Proxy WithFields(fields Fields) *Proxy WithError(err error) *Proxy WithContext(ctx context.Context) *Proxy Debugf(format string, args ...interface{}) Infof(format string, args ...interface{}) Printf(format string, args ...interface{}) Warnf(format string, args ...interface{}) Warningf(format string, args ...interface{}) Errorf(format string, args ...interface{}) Fatalf(format string, args ...interface{}) Panicf(format string, args ...interface{}) Debug(args ...interface{}) Info(args ...interface{}) Print(args ...interface{}) Warn(args ...interface{}) Warning(args ...interface{}) Error(args ...interface{}) Fatal(args ...interface{}) Panic(args ...interface{}) Debugln(args ...interface{}) Infoln(args ...interface{}) Println(args ...interface{}) Warnln(args ...interface{}) Warningln(args ...interface{}) Errorln(args ...interface{}) Fatalln(args ...interface{}) Panicln(args ...interface{}) Tracef(format string, args ...interface{}) Trace(args ...interface{}) Traceln(args ...interface{}) }
Logger is interface in proxy, originally in logrus it is a struct. Can be useful to mock the logging interface but can cause compile errors when pointer is in use.
type Options ¶ added in v0.0.5
type Options struct {
NoExit bool // If true, the process will not exit on fatal/panic log entries.
}
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
Proxy is a proxy type for logrus.Logger
func NewDiscardProxy ¶
func NewDiscardProxy() *Proxy
NewDiscardProxy creates a new Proxy which discards all logs. This is the default logger when not set.
func NewEntry ¶
func NewEntry(fl FieldLogger) *Proxy
NewEntry creates a new Proxy for the standard logger. Proxy must be passed as an argument.
func NewProxy ¶
func NewProxy() *Proxy
NewProxy creates a new Proxy for the standard logger. It does not exit on fatal errors. To do that, use NewProxyFor with exitOnFatal set to true.
func NewProxyFor ¶
NewProxyFor creates a new Proxy for a particular logger. When options.NoExit is true, the logger will not exit the process on fatal errors and panic on panic calls.