log

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: AGPL-3.0 Imports: 11 Imported by: 8

Documentation

Index

Constants

View Source
const (
	LogLevelDebug = "debug"
	LogLevelInfo  = "info"
	LogLevelWarn  = "warn"
	LogLevelError = "error"

	RFC3339Milli = "2006-01-02T15:04:05.000Z07:00" // like time.RFC3339Nano but with 3 fixed-width decimals
)

Variables

This section is empty.

Functions

func Debug

func Debug(args ...any)

Debug sends a debug level log message

func DebugTime added in v0.0.4

func DebugTime(msg string, start time.Time, keyvalues ...any)

DebugTime logs a debug message with a normalized `took` field.

func Debugf

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

Debugf sends a formatted debug level log message

func Debugw

func Debugw(msg string, keyvalues ...any)

Debugw sends a debug level log message with key-value pairs.

func EnablePanicOnError

func EnablePanicOnError(testName string) zerolog.Logger

EnablePanicOnError installs a hook on the current logger that makes it panic when Error level logs occur. Returns the previous logger so it can be restored later. This is useful for integration tests to catch unexpected errors.

func EnablePanicOnErrorWithHandler

func EnablePanicOnErrorWithHandler(testName string, delay time.Duration, handler func(string)) zerolog.Logger

EnablePanicOnErrorWithHandler installs a hook on the current logger that triggers the handler after the provided delay when Error level logs occur. If handler is nil, it panics with the error message.

func Error

func Error(args ...any)

Error sends an error level log message

func Errorf

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

Errorf sends a formatted error level log message

func Errorw

func Errorw(err error, msg string)

Errorw sends an error level log message with a special format for errors.

func Fatal

func Fatal(args ...any)

Fatal sends a fatal level log message

func Fatalf

func Fatalf(template string, args ...any)

Fatalf sends a formatted fatal level log message

func Info

func Info(args ...any)

Info sends an info level log message

func InfoTime added in v0.0.4

func InfoTime(msg string, start time.Time, keyvalues ...any)

InfoTime logs an info message with a normalized `took` field.

func Infof

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

Infof sends a formatted info level log message

func Infow

func Infow(msg string, keyvalues ...any)

Infow sends an info level log message with key-value pairs.

func Init

func Init(level, output string, errorOutput io.Writer)

func Level

func Level() string

Level returns the current log level

func Logger

func Logger() *zerolog.Logger

Logger provides access to the global logger (zerolog).

func Monitor

func Monitor(msg string, args map[string]any)

Monitor is a wrapper around Info that allows passing a map of key-value pairs. This is useful for structured logging and monitoring. The caller information is skipped.

func RestoreLogger

func RestoreLogger(previousLogger zerolog.Logger)

RestoreLogger restores a previously saved logger, removing any hooks.

func Warn

func Warn(args ...any)

Warn sends a warn level log message

func Warnf

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

Warnf sends a formatted warn level log message

func Warnw

func Warnw(msg string, keyvalues ...any)

Warnw sends a warning level log message with key-value pairs.

Types

This section is empty.

Jump to

Keyboard shortcuts

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