logging

package
v0.3.22 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package logging provides structured logging for goplexcli using slog. It supports configurable log levels and can be enabled via --verbose flag.

Index

Constants

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

Level constants for convenience

Variables

This section is empty.

Functions

func Debug

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

Debug logs a debug message

func Enabled

func Enabled(level slog.Level) bool

Enabled returns true if the given level is enabled

func Error

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

Error logs an error message

func Info

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

Info logs an info message

func Init

func Init(opts ...Option)

Init initializes the logger with the specified options. This should be called early in main() before any logging occurs. If not called, a default logger will be created on first use.

func IsVerbose

func IsVerbose() bool

IsVerbose returns true if verbose (debug) logging is enabled

func Logger

func Logger() *slog.Logger

Logger returns the underlying slog.Logger for advanced use cases

func SetLevel

func SetLevel(level slog.Level)

SetLevel changes the log level at runtime

func SetVerbose

func SetVerbose(verbose bool)

SetVerbose is a convenience function to enable/disable verbose logging

func Warn

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

Warn logs a warning message

func With

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

With returns a new logger with the given attributes

Types

type Option

type Option func(*config)

Option is a functional option for configuring the logger

func WithLevel

func WithLevel(level slog.Level) Option

WithLevel sets the minimum log level

func WithOutput

func WithOutput(w io.Writer) Option

WithOutput sets the output destination

func WithVerbose

func WithVerbose(verbose bool) Option

WithVerbose enables verbose (debug) logging

Jump to

Keyboard shortcuts

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