logger

package
v0.100.4-rc.2 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close added in v0.28.0

func Close()

Close closes the logger and flushes any buffered entries

func ContextWithLogger

func ContextWithLogger(ctx context.Context, l *zap.Logger) context.Context

ContextWithLogger attaches a logger to the context

func Debug

func Debug(msg string, args ...any)

Debug logs a debug message

func Error

func Error(msg string, args ...any)

Error logs an error message

func Fatal added in v0.28.0

func Fatal(msg string, args ...any)

Fatal logs a fatal message and exits

func FromContext

func FromContext(ctx context.Context) *zap.Logger

FromContext retrieves the logger from context Falls back to global logger during migration period

func GetGlobalLogger

func GetGlobalLogger() *zap.Logger

GetGlobalLogger returns the global logger instance Useful for services that need to store a logger reference

func Info

func Info(msg string, args ...any)

Info logs an info message

func Init

func Init(cfg Config)

Init initializes the global logger (for migration period)

func L

func L(ctx context.Context) *zap.Logger

L is a shorthand for FromContext (matches zap.L() pattern)

func NewLogger

func NewLogger(cfg Config) (*zap.Logger, error)

NewLogger creates a new configured logger instance

func NopContext

func NopContext() context.Context

NopContext creates a context with a no-op logger (for benchmarks or when logs are not needed)

func Sugar

func Sugar(ctx context.Context) *zap.SugaredLogger

Sugar returns a sugared logger from context

func Sync added in v0.28.0

func Sync() error

Sync flushes any buffered log entries

func TestContext

func TestContext() (context.Context, *observer.ObservedLogs)

TestContext creates a context with a test logger Returns both the context and the observed logs for assertions

func TestLogger

func TestLogger() (*zap.Logger, *observer.ObservedLogs)

TestLogger creates a logger that captures logs for assertions The returned ObservedLogs can be used to verify log messages in tests

func Warn

func Warn(msg string, args ...any)

Warn logs a warning message

func With

func With(ctx context.Context, fields ...zap.Field) context.Context

With creates a child context with additional logger fields

Types

type Config

type Config struct {
	Verbose bool
	Debug   bool
	LogDir  string
}

Config for logger initialization

Jump to

Keyboard shortcuts

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