logging

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package logging provides structured logging for pdf-cli.

Index

Constants

This section is empty.

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 Init

func Init(level Level, format Format)

Init initializes the global logger with the given level and format.

func Reset

func Reset()

Reset resets the global logger (for testing).

func Warn

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

Warn logs at warn level.

Types

type Format

type Format string

Format represents a log format.

const (
	FormatText Format = "text"
	FormatJSON Format = "json"
)

func ParseFormat

func ParseFormat(s string) Format

ParseFormat parses a log format string.

type Level

type Level string

Level represents a log level.

const (
	LevelDebug  Level = "debug"
	LevelInfo   Level = "info"
	LevelWarn   Level = "warn"
	LevelError  Level = "error"
	LevelSilent Level = "silent"
)

func ParseLevel

func ParseLevel(s string) Level

ParseLevel parses a log level string.

func (Level) ToSlogLevel

func (l Level) ToSlogLevel() slog.Level

ToSlogLevel converts Level to slog.Level.

type Logger

type Logger struct {
	*slog.Logger
	// contains filtered or unexported fields
}

Logger wraps slog for pdf-cli logging.

func Get

func Get() *Logger

Get returns the global logger, initializing with defaults if needed.

func New

func New(level Level, format Format, w io.Writer) *Logger

New creates a new logger with the given level, format, and output.

func With

func With(args ...any) *Logger

With returns a logger with additional attributes.

func (*Logger) Format

func (l *Logger) Format() Format

Format returns the logger's format.

func (*Logger) Level

func (l *Logger) Level() Level

Level returns the logger's level.

Jump to

Keyboard shortcuts

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