logger

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LevelDebug = slog.LevelDebug
	LevelInfo  = slog.LevelInfo
	LevelWarn  = slog.LevelWarn
	LevelError = slog.LevelError
)

Variables

This section is empty.

Functions

func Debug

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

Debug logs at debug level.

func Error

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

Error logs at error level.

func Info

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

Info logs at info level.

func SetGlobal

func SetGlobal(l *Logger)

SetGlobal sets the global logger instance.

func Warn

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

Warn logs at warn level.

Types

type Config

type Config struct {
	Level  string
	Format string // "json" or "text"
	Output io.Writer
}

Config holds the logger configuration.

type Level

type Level = slog.Level

Level represents the log level.

type Logger

type Logger struct {
	*slog.Logger
}

Logger is a wrapper around slog.Logger.

func Context

func Context(ctx context.Context) *Logger

Context returns a logger with the given context.

func Get

func Get() *Logger

Get returns the global logger instance.

func New

func New(cfg *Config) *Logger

New creates a new Logger instance.

func With

func With(args ...any) *Logger

With returns a logger with the given attributes.

Jump to

Keyboard shortcuts

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