Documentation
¶
Overview ¶
Package logger provides structured logging for Clean Wizard.
This package wraps charm.land/log/v2 (https://github.com/charmbracelet/log) to provide beautiful, colorful, structured logging throughout the application. It integrates seamlessly with the existing charmbracelet ecosystem (huh, lipgloss, bubbletea).
Usage:
import "github.com/LarsArtmann/clean-wizard/internal/logger"
func main() {
logger.Init(false) // or true for development
defer logger.Sync()
logger.Info("application started",
"version", version.Version,
)
}
Index ¶
- Variables
- func CleanerLogger(name string) *log.Logger
- func Debug(msg string, keyvals ...any)
- func Error(msg string, keyvals ...any)
- func Fatal(msg string, keyvals ...any)
- func GetSlogLogger() *slog.Logger
- func Info(msg string, keyvals ...any)
- func Init(development bool)
- func InitWithLevel(levelStr string, development bool)
- func SetLevel(level string)
- func Sync()
- func Warn(msg string, keyvals ...any)
- func With(keyvals ...any) *log.Logger
- func WithPrefix(name string) *log.Logger
Constants ¶
This section is empty.
Variables ¶
var L *log.Logger
L is the global logger instance. Use this for all logging throughout the application.
var StdLogger *slog.Logger
StdLogger provides a standard slog.Logger for interoperability.
Functions ¶
func CleanerLogger ¶
CleanerLogger returns a logger for a specific cleaner.
func GetSlogLogger ¶
GetSlogLogger returns the standard slog.Logger for interoperability.
func Init ¶
func Init(development bool)
Init initializes the global logger.
In development mode, logs are colorful and human-readable. In production mode, logs are JSON-formatted for structured parsing.
Example:
logger.Init(true) // Development: colorful console output logger.Init(false) // Production: JSON output
func InitWithLevel ¶
InitWithLevel initializes the logger with a specific level.
Valid levels: debug, info, warn, error, fatal.
func WithPrefix ¶
WithPrefix creates a child logger with a sub-scope name.
Types ¶
This section is empty.