logger

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Logger *slog.Logger
)

Functions

func Debug

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

func Error

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

func Fatal

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

func Get

func Get() *slog.Logger

func Info

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

func Init

func Init(cfg *config.LoggerConfig) error

func Named

func Named(name string) *slog.Logger

func NewConditionalSourceHandler

func NewConditionalSourceHandler(handler slog.Handler, showSourceForLevels ...slog.Level) slog.Handler

NewConditionalSourceHandler wraps a handler to conditionally show source location based on log level. Source location is only shown for the specified levels. This is useful for reducing log volume in production while maintaining debuggability for important log levels.

The wrapped handler should have AddSource: false in its options. This wrapper will conditionally add source attributes for specified levels.

Example:

handler := NewConditionalSourceHandler(
    tint.NewHandler(os.Stdout, opts),
    slog.LevelWarn,
    slog.LevelError,
)

func SetLevel

func SetLevel(level slog.Level)

func Sync

func Sync() error

func Warn

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

func WithComponent

func WithComponent(component string) *slog.Logger

func WithFields

func WithFields(args ...any) *slog.Logger

Types

type Interface

type Interface interface {
	Debug(msg string, args ...any)
	Info(msg string, args ...any)
	Warn(msg string, args ...any)
	Error(msg string, args ...any)
	Fatal(msg string, args ...any)
	With(args ...any) Interface
	Named(name string) Interface

	Debugw(msg string, keysAndValues ...interface{})
	Infow(msg string, keysAndValues ...interface{})
	Warnw(msg string, keysAndValues ...interface{})
	Errorw(msg string, keysAndValues ...interface{})
	Fatalw(msg string, keysAndValues ...interface{})
}

func NewLogger

func NewLogger() Interface

func NewLoggerWithSlog

func NewLoggerWithSlog(slogLog *slog.Logger) Interface

Jump to

Keyboard shortcuts

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