logger

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package logger provides the Logger contract plus zap, memory, and noop implementations.

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Options(
	fx.Provide(newLogger),
)

Module provides a Logger from a logger.Config supplied by the service.

Functions

This section is empty.

Types

type Config

type Config struct {
	Driver string // zap | memory | noop
	Level  string // debug | info | warn | error | fatal | panic
	Format string // time layout for log timestamps
	Path   string // output path for the zap driver
	Debug  bool
}

Config selects and configures the logger driver.

type Log

type Log struct {
	Level   string
	Message string
	Fields  []zap.Field
}

type Logger

type Logger interface {
	Debug(msg string, fields ...zap.Field)
	Info(msg string, fields ...zap.Field)
	Warn(msg string, fields ...zap.Field)
	Error(msg string, fields ...zap.Field)
}

Logger is the interface for logging messages with different levels and structured fields.

func New

func New(cfg Config) (Logger, error)

New builds a Logger for the configured driver.

type Memory

type Memory struct {
	// contains filtered or unexported fields
}

func NewMemory

func NewMemory() *Memory

func (*Memory) Debug

func (m *Memory) Debug(msg string, fields ...zap.Field)

func (*Memory) Entries

func (m *Memory) Entries() []Log

func (*Memory) Error

func (m *Memory) Error(msg string, fields ...zap.Field)

func (*Memory) Info

func (m *Memory) Info(msg string, fields ...zap.Field)

func (*Memory) Warn

func (m *Memory) Warn(msg string, fields ...zap.Field)

type Noop

type Noop struct{}

func NewNoop

func NewNoop() Noop

func (Noop) Debug

func (Noop) Debug(_ string, _ ...zap.Field)

func (Noop) Error

func (Noop) Error(_ string, _ ...zap.Field)

func (Noop) Info

func (Noop) Info(_ string, _ ...zap.Field)

func (Noop) Warn

func (Noop) Warn(_ string, _ ...zap.Field)

type Zap

type Zap struct {
	// contains filtered or unexported fields
}

func NewZap

func NewZap(c Config) (*Zap, error)

func (*Zap) Debug

func (z *Zap) Debug(msg string, fields ...base.Field)

func (*Zap) Error

func (z *Zap) Error(msg string, fields ...base.Field)

func (*Zap) Info

func (z *Zap) Info(msg string, fields ...base.Field)

func (*Zap) Stop

func (z *Zap) Stop(_ context.Context) error

func (*Zap) Warn

func (z *Zap) Warn(msg string, fields ...base.Field)

Jump to

Keyboard shortcuts

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