logger

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2026 License: MIT Imports: 4 Imported by: 0

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

Constants

This section is empty.

Variables

L is the global logger instance. Use this for all logging throughout the application.

View Source
var StdLogger *slog.Logger

StdLogger provides a standard slog.Logger for interoperability.

Functions

func CleanerLogger

func CleanerLogger(name string) *log.Logger

CleanerLogger returns a logger for a specific cleaner.

func Debug

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

Debug logs a debug message.

func Error

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

Error logs an error message.

func Fatal

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

Fatal logs a fatal message and exits.

func GetSlogLogger

func GetSlogLogger() *slog.Logger

GetSlogLogger returns the standard slog.Logger for interoperability.

func Info

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

Info logs an info message.

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

func InitWithLevel(levelStr string, development bool)

InitWithLevel initializes the logger with a specific level.

Valid levels: debug, info, warn, error, fatal.

func SetLevel

func SetLevel(level string)

SetLevel changes the log level at runtime.

func Sync

func Sync()

Sync flushes any buffered log entries. Call this before program exit.

func Warn

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

Warn logs a warning message.

func With

func With(keyvals ...any) *log.Logger

With creates a child logger with additional fields.

func WithPrefix

func WithPrefix(name string) *log.Logger

WithPrefix creates a child logger with a sub-scope name.

Types

This section is empty.

Jump to

Keyboard shortcuts

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