logger

package
v7.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(msg string, ctx ...Ctx)

Debug logs a message (with optional context) at the DEBUG log level.

func Debugf

func Debugf(format string, args ...any)

Debugf logs at the DEBUG log level using a standard printf format string.

func Error

func Error(msg string, ctx ...Ctx)

Error logs a message (with optional context) at the ERROR log level.

func Errorf

func Errorf(format string, args ...any)

Errorf logs at the ERROR log level using a standard printf format string.

func GetStack

func GetStack() string

GetStack will convert the Go stack into a string suitable for logging.

func Info

func Info(msg string, ctx ...Ctx)

Info logs a message (with optional context) at the INFO log level.

func Infof

func Infof(format string, args ...any)

Infof logs at the INFO log level using a standard printf format string.

func InitLogger

func InitLogger(filepath string, syslogName string, verbose bool, debug bool, hook logrus.Hook) error

InitLogger initializes a full logging instance.

func NewSlogHandler

func NewSlogHandler(prefix string, target func(msg string, ctx ...Ctx)) slog.Handler

NewSlogHandler returns a slog.Handler implementation that forwards to our own logger.

func Panic

func Panic(msg string, ctx ...Ctx)

Panic logs a message (with optional context) at the PANIC log level.

func Panicf

func Panicf(format string, args ...any)

Panicf logs at the PANIC log level using a standard printf format string.

func Pretty

func Pretty(input any) string

Pretty will attempt to convert any Go structure into a string suitable for logging.

func Trace

func Trace(msg string, ctx ...Ctx)

Trace logs a message (with optional context) at the TRACE log level.

func Tracef

func Tracef(format string, args ...any)

Tracef logs at the TRACE log level using a standard printf format string.

func Warn

func Warn(msg string, ctx ...Ctx)

Warn logs a message (with optional context) at the WARNING log level.

func WarnOnError added in v7.2.0

func WarnOnError(f func() error, msg string, ctx ...Ctx)

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 Warnf

func Warnf(format string, args ...any)

Warnf logs at the WARNING log level using a standard printf format string.

Types

type Ctx

type Ctx logrus.Fields

Ctx is the logging context.

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)
	AddContext(Ctx) Logger
}

Logger is the main logging interface.

var Log Logger

Log contains the logger used by all the logging functions.

func AddContext

func AddContext(ctx Ctx) Logger

AddContext returns a new logger with the context added.

Jump to

Keyboard shortcuts

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