Documentation
¶
Index ¶
- func Debug(msg string, ctx ...Ctx)
- func Debugf(format string, args ...any)
- func Error(msg string, ctx ...Ctx)
- func Errorf(format string, args ...any)
- func GetStack() string
- func Info(msg string, ctx ...Ctx)
- func Infof(format string, args ...any)
- func InitLogger(filepath string, syslogName string, verbose bool, debug bool, hook logrus.Hook) error
- func NewSlogHandler(target SlogFunc) slog.Handler
- func Panic(msg string, ctx ...Ctx)
- func Panicf(format string, args ...any)
- func Pretty(input any) string
- func Trace(msg string, ctx ...Ctx)
- func Tracef(format string, args ...any)
- func Warn(msg string, ctx ...Ctx)
- func WarnOnError(f func() error, msg string, ctx ...Ctx)
- func WarnOnErrorExcept(f func() error, ignore []error, msg string, ctx ...Ctx)
- func Warnf(format string, args ...any)
- type Ctx
- type Logger
- type SlogFunc
- type SlogLevel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetStack ¶
func GetStack() string
GetStack will convert the Go stack into a string suitable for logging.
func InitLogger ¶
func InitLogger(filepath string, syslogName string, verbose bool, debug bool, hook logrus.Hook) error
InitLogger initializes a full logging instance.
func NewSlogHandler ¶
NewSlogHandler returns a slog.Handler implementation that forwards to our own logger.
func WarnOnError ¶ added in v7.0.1
WarnOnError calls the provided function and, if it returns an error, logs that error as a warning together with the provided message and optional context.
func WarnOnErrorExcept ¶ added in v7.0.1
WarnOnErrorExcept behaves like WarnOnError but doesn't warn for any error matching (via errors.Is) one of the provided ignored errors.
Types ¶
type Logger ¶
type Logger interface {
Panic(msg string, args ...Ctx)
Fatal(msg string, args ...Ctx)
Error(msg string, args ...Ctx)
Warn(msg string, args ...Ctx)
Info(msg string, args ...Ctx)
Debug(msg string, args ...Ctx)
Trace(msg string, args ...Ctx)
WarnOnErrorExcept(err error, ignore []error, msg string, args ...Ctx)
AddContext(Ctx) Logger
}
Logger is the main logging interface.
var Log Logger
Log contains the logger used by all the logging functions.
func AddContext ¶
AddContext returns a new logger with the context added.
type SlogFunc ¶ added in v7.6.0
SlogFunc represents the logging function.
func DefaultSlogLogger ¶ added in v7.6.0
DefaultSlogLogger is the default wrapper for slog parameters to our own logger.
type SlogLevel ¶ added in v7.6.0
SlogLevel is a convenience for slog.Level.
const ( // SlogWarn is a convenience for slog.LevelWarn. SlogWarn SlogLevel = slog.LevelWarn // SlogError is a convenience for SlogLevelError. SlogError SlogLevel = slog.LevelError // SlogDebug is a convenience for SlogLevelDebug. SlogDebug SlogLevel = slog.LevelDebug // SlogInfo is a convenience for SlogLevelInfo. SlogInfo SlogLevel = slog.LevelInfo )