log

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package log provides centralized logging functionality for the opnDossier application.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidLogLevel is returned when an unrecognized log level is specified.
	ErrInvalidLogLevel = errors.New("invalid log level")
	// ErrInvalidLogFormat is returned when an unrecognized log format is specified.
	ErrInvalidLogFormat = errors.New("invalid log format")
)

Error definitions for validation.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Level is the log level (debug, info, warn, error)
	Level string
	// Format is the output format (text, json)
	Format string
	// Output is the writer to output logs to
	Output io.Writer
	// ReportCaller enables caller reporting
	ReportCaller bool
	// ReportTimestamp enables timestamp reporting
	ReportTimestamp bool
}

Config holds the logger configuration options.

type Logger

type Logger struct {
	*log.Logger
}

Logger is the application logger instance.

func New

func New(cfg Config) (*Logger, error)

New returns a new Logger instance configured according to the provided Config. It validates the log level and format, sets default output to standard error if unspecified, and applies options for caller and timestamp reporting. The logger's output format and level are set based on the configuration. Returns an error if the log level or format is invalid.

func (*Logger) Sub

func (l *Logger) Sub(subsystem string) *Logger

Sub creates a sub-logger with the specified subsystem name.

func (*Logger) WithContext

func (l *Logger) WithContext(_ context.Context) *Logger

WithContext returns a logger with the provided context. Note: charmbracelet/log doesn't have built-in context support, but we maintain this method signature for compatibility.

func (*Logger) WithFields

func (l *Logger) WithFields(keyvals ...any) *Logger

WithFields returns a logger with the specified key-value pairs.

func (*Logger) WithPrefix

func (l *Logger) WithPrefix(prefix string) *Logger

WithPrefix returns a logger with the specified prefix.

Jump to

Keyboard shortcuts

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