logger

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: May 18, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package logger provides structured JSON logging with level filtering.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Field

type Field struct {
	Key   string
	Value interface{}
}

Field is a key-value pair for structured log context.

func Err

func Err(err error) Field

Err creates an error log field.

func F

func F(key string, value interface{}) Field

F creates a log field.

type Level

type Level int

Level represents the severity of a log message.

const (
	LevelDebug Level = iota
	LevelInfo
	LevelError
	LevelFatal
)

func ParseLevel

func ParseLevel(s string) Level

ParseLevel parses a log level string. Defaults to info for unknown values.

type Logger

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

Logger writes structured JSON log entries to stderr.

func New

func New(level Level) *Logger

New creates a Logger that emits messages at or above the given level.

func (*Logger) Debug

func (l *Logger) Debug(msg string, fields ...Field)

Debug logs a message at debug level.

func (*Logger) Error

func (l *Logger) Error(msg string, fields ...Field)

Error logs a message at error level.

func (*Logger) Fatal

func (l *Logger) Fatal(msg string, fields ...Field)

Fatal logs a message at fatal level and exits with code 1.

func (*Logger) Info

func (l *Logger) Info(msg string, fields ...Field)

Info logs a message at info level.

Jump to

Keyboard shortcuts

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