logging

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package logging provides structured logging capabilities using zerolog.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(msg string)

Debug logs a debug message

func Debugf

func Debugf(format string, v ...interface{})

Debugf logs a formatted debug message

func Error

func Error(msg string)

Error logs an error message

func Errorf

func Errorf(format string, v ...interface{})

Errorf logs a formatted error message

func Fatal

func Fatal(msg string)

Fatal logs a fatal message and exits

func Fatalf

func Fatalf(format string, v ...interface{})

Fatalf logs a formatted fatal message and exits

func Info

func Info(msg string)

Info logs an info message

func Infof

func Infof(format string, v ...interface{})

Infof logs a formatted info message

func Init

func Init(config *Config)

Init initializes the global logger with the given configuration

func Panic

func Panic(msg string)

Panic logs a panic message and panics

func Panicf

func Panicf(format string, v ...interface{})

Panicf logs a formatted panic message and panics

func Warn

func Warn(msg string)

Warn logs a warning message

func Warnf

func Warnf(format string, v ...interface{})

Warnf logs a formatted warning message

Types

type Config

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

	// Console enables console output
	Console bool

	// ConsoleJSON enables JSON format for console output
	ConsoleJSON bool

	// File enables file output
	File bool

	// Filename is the file to write logs to
	Filename string

	// MaxSize is the maximum size in megabytes of the log file
	MaxSize int

	// MaxBackups is the maximum number of old log files to retain
	MaxBackups int

	// MaxAge is the maximum number of days to retain old log files
	MaxAge int

	// Compress determines if the rotated log files should be compressed
	Compress bool
}

Config holds logger configuration

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns default logger configuration

type Level

type Level int

Level represents log level

const (
	// DebugLevel has verbose message
	DebugLevel Level = iota
	// InfoLevel is default log level
	InfoLevel
	// WarnLevel is for warning conditions
	WarnLevel
	// ErrorLevel is for error conditions
	ErrorLevel
	// FatalLevel is for fatal conditions
	FatalLevel
	// PanicLevel is for panic conditions
	PanicLevel
)

type Logger

type Logger struct {
	*zerolog.Logger
	// contains filtered or unexported fields
}

Logger wraps zerolog logger

func GetLogger

func GetLogger() *Logger

GetLogger returns the global logger instance

func WithError

func WithError(err error) *Logger

WithError adds an error field to the logger

func WithField

func WithField(key string, value interface{}) *Logger

WithField adds a field to the logger

func WithFields

func WithFields(fields map[string]interface{}) *Logger

WithFields adds multiple fields to the logger

func (*Logger) With

func (l *Logger) With(fields map[string]interface{}) *Logger

With creates a child logger with the given fields

func (*Logger) WithError

func (l *Logger) WithError(err error) *Logger

WithError creates a child logger with the error field set

Jump to

Keyboard shortcuts

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