internal

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package internal holds the logger backend adapters (zap / slog) and the shared OutputFormat / level vocabulary the public logger package translates user input into.

Index

Constants

View Source
const (
	LogLevelDebug    = -1
	LogLevelInfo     = 0
	LogLevelWarn     = 1
	LogLevelError    = 2
	LogLevelCritical = 3
)

Variables

This section is empty.

Functions

func NewSlogLogger

func NewSlogLogger(opts ...SlogOption) *slogLogger

NewSlogLogger creates a new slog logger with optional configuration

func NewZapLogger

func NewZapLogger(opts ...ZapOption) *zapLogger

NewZapLogger creates a new zap logger with optional configuration

Types

type Logger

type Logger interface {
	Enabled(level int) bool
	WithContext(ctx context.Context) Logger
	WithFields(fields map[string]any) Logger
	WithKeysAndValues(keysAndValues ...any) Logger
	Debug(msg string, args ...any)
	Warn(msg string, args ...any)
	Info(msg string, args ...any)
	Error(msg string, args ...any)
	Critical(msg string, args ...any)
}

Logger is the interface for internal logger implementations to avoid circular dependencies

type OutputFormat

type OutputFormat string
const (
	JSONFormat OutputFormat = "json"
	TextFormat OutputFormat = "text"
)

type SlogOption

type SlogOption func(*slogConfig)

SlogOption defines a function that can modify the slog logger configuration

func WithSlogFormat

func WithSlogFormat(format OutputFormat) SlogOption

WithSlogFormat sets the output format

func WithSlogLevel

func WithSlogLevel(level int) SlogOption

WithSlogLevel sets the log level

func WithSlogOutput

func WithSlogOutput(output io.Writer) SlogOption

WithSlogOutput sets the output writer

type ZapOption

type ZapOption func(*zapConfig)

ZapOption defines a function that can modify the zap logger configuration

func WithZapDevelopmentConfig

func WithZapDevelopmentConfig() ZapOption

WithZapDevelopmentConfig sets the development configuration for zap logger

func WithZapLevel

func WithZapLevel(level int) ZapOption

WithZapLevel sets the log level

func WithZapOutput

func WithZapOutput(output io.Writer) ZapOption

WithZapOutput sets the output writer

func WithZapProductionConfig

func WithZapProductionConfig() ZapOption

WithZapProductionConfig sets the production configuration for zap logger

Jump to

Keyboard shortcuts

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