logger

package
v0.0.4-rc.1 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package logger provides a structured logging interface for MALT. It wraps go.uber.org/zap for high-performance logging with support for performance analysis and debugging.

Index

Constants

This section is empty.

Variables

View Source
var (
	DebugLevel = zapcore.DebugLevel
	InfoLevel  = zapcore.InfoLevel
	WarnLevel  = zapcore.WarnLevel
	ErrorLevel = zapcore.ErrorLevel
)

Log levels.

View Source
var (
	String  = zap.String
	Int     = zap.Int
	Int64   = zap.Int64
	Float64 = zap.Float64
	Bool    = zap.Bool
	Err     = zap.Error // Use Err for zap.Error field
	Any     = zap.Any
)

Common field constructors.

Logger is the global logger instance.

Functions

func Close

func Close() error

Close closes the logger and releases any file handles. This should be called when the logger is no longer needed, especially important for tests using temporary directories to avoid file locking issues on Windows.

func Debug

func Debug(msg string, fields ...Field)

Debug logs a debug message.

func Error

func Error(msg string, fields ...Field)

Error logs an error message.

func Fatal

func Fatal(msg string, fields ...Field)

Fatal logs a fatal message and exits.

func Info

func Info(msg string, fields ...Field)

Info logs an info message.

func Init

func Init(cfg Config) error

Init initializes the global logger with the given config.

func InitDevelopment

func InitDevelopment() error

InitDevelopment initializes a development logger.

func InitProduction

func InitProduction() error

InitProduction initializes a production logger.

func Named

func Named(name string) *zap.SugaredLogger

Named returns a logger with a name prefix.

func SetLevel

func SetLevel(level Level)

SetLevel changes the log level dynamically.

func Sync

func Sync() error

Sync flushes any buffered logs.

func Warn

func Warn(msg string, fields ...Field)

Warn logs a warning message.

func With

func With(fields ...Field) *zap.SugaredLogger

With returns a logger with additional fields.

Types

type Config

type Config struct {
	// Level is the minimum log level.
	Level Level

	// Development mode uses human-friendly output.
	Development bool

	// OutputPaths are paths to write logs to.
	// Defaults to ["stdout"].
	OutputPaths []string

	// ErrorOutputPaths are paths to write internal errors to.
	// Defaults to ["stderr"].
	ErrorOutputPaths []string
}

Config holds logger configuration.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the default logger configuration.

func DevelopmentConfig

func DevelopmentConfig() Config

DevelopmentConfig returns a development-friendly configuration.

type Field

type Field = zap.Field

Field represents a structured log field.

type Level

type Level = zapcore.Level

Level represents log severity level.

Jump to

Keyboard shortcuts

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