logger

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2026 License: Apache-2.0, MIT Imports: 16 Imported by: 0

Documentation

Overview

Package logger wires LogLayer to console or file sinks.

Index

Constants

View Source
const (
	// DefaultBufferSize is the async queue capacity when unset.
	DefaultBufferSize = 4096

	// DefaultFlushTimeout bounds shutdown and fatal-log flushing.
	DefaultFlushTimeout = 5 * time.Second
)

Variables

View Source
var (
	// ErrInvalidLevel reports an unknown level.
	ErrInvalidLevel = errors.New("logger: invalid level (want trace|debug|info|warn|error|fatal|panic)")

	// ErrInvalidOutput reports an unknown output.
	ErrInvalidOutput = errors.New("logger: invalid output (want console|file)")

	// ErrInvalidFormat reports an unknown format.
	ErrInvalidFormat = errors.New("logger: invalid format (want pretty|structured)")

	// ErrPrettyRequiresConsole reports pretty output requested for a file.
	ErrPrettyRequiresConsole = errors.New("logger: pretty format requires console output")

	// ErrFileRequired reports file output without a path.
	ErrFileRequired = errors.New("logger: file output requires a file path")
)

Errors returned by New.

Functions

func QueueLogger

func QueueLogger(log Logger) queue.Logger

QueueLogger adapts the application logger to the queue logger interface.

func Slog

func Slog(log Logger) *slog.Logger

Slog adapts the shared logger to slog.Logger.

Types

type Logger

type Logger = *loglayer.LogLayer

Logger is the application logging contract.

func New

func New(opts Options) (Logger, io.Closer, error)

New builds the logger over an asynchronous transport.

func NewMock

func NewMock() Logger

NewMock returns a silent logger for tests and optional components.

type Options

type Options struct {
	// Level accepts trace, debug, info, warn, error, fatal, or panic.
	Level string

	// Output: "console" (default) or "file".
	Output string

	// Format accepts structured (JSON) or pretty (console only).
	Format string

	// NoColor disables colors in pretty output.
	NoColor bool

	// File is the path for file output.
	File string

	// Buffer is async queue capacity. Zero uses DefaultBufferSize.
	Buffer int
}

Options selects the sink and format for New.

Jump to

Keyboard shortcuts

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