logging

package
v0.0.0-...-87e4b86 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

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

Debug logs a message at debug level

func Error

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

Error logs a message at error level

func GetLogger

func GetLogger() *slog.Logger

GetLogger returns the default logger

func Info

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

Info logs a message at info level

func Initialize

func Initialize(cfg *Config)

Initialize sets up the logger with the given configuration

func Warn

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

Warn logs a message at warn level

func WithContext

func WithContext(ctx context.Context) *slog.Logger

WithContext returns a logger with context

func WithField

func WithField(key string, value any) *slog.Logger

WithField adds a field to the logger

func WithFields

func WithFields(fields map[string]any) *slog.Logger

WithFields adds multiple fields to the logger

Types

type Config

type Config struct {
	Level      LogLevel
	Output     io.Writer
	JSONFormat bool
}

Config holds logging configuration

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default logging configuration

type LogLevel

type LogLevel string

LogLevel represents logging levels

const (
	// LogLevelDebug is for detailed debug information
	LogLevelDebug LogLevel = "debug"
	// LogLevelInfo is for general operational information
	LogLevelInfo LogLevel = "info"
	// LogLevelWarn is for warning conditions that should be addressed
	LogLevelWarn LogLevel = "warn"
	// LogLevelError is for error conditions that prevent normal operation
	LogLevelError LogLevel = "error"
)

Jump to

Keyboard shortcuts

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