logger

package
v0.0.0-...-fd57926 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Global logger instance

Functions

func InitLogger

func InitLogger(config LoggerConfig) error

InitLogger initializes the logger with the provided configuration

func LogDebug

func LogDebug(message string, fields map[string]interface{})

func LogError

func LogError(message string, err error, fields map[string]interface{})

func LogFatal

func LogFatal(message string, fields map[string]interface{})

func LogInfo

func LogInfo(message string, fields map[string]interface{})

Log functions

func LogWarn

func LogWarn(message string, fields map[string]interface{})

func SimpleInitLogger

func SimpleInitLogger(debug bool, logFormat string)

SimpleInitLogger provides backward compatibility with the old init function

func Sync

func Sync() error

Sync flushes any buffered log entries

func WithError

func WithError(err error) *zap.SugaredLogger

WithError returns a logger with an error field added to every log

func WithField

func WithField(key string, value interface{}) *zap.SugaredLogger

WithField returns a logger with a field added to every log

func WithFields

func WithFields(fields map[string]interface{}) *zap.SugaredLogger

WithFields returns a logger with multiple fields added to every log

Types

type LoggerConfig

type LoggerConfig struct {
	Debug     bool   // Enable debug level logging
	LogFormat string // "json" or "human"
	LogFile   string // Path to log file (optional)
}

LoggerConfig contains configuration for the logger

func DefaultConfig

func DefaultConfig() LoggerConfig

DefaultConfig returns a default configuration

Jump to

Keyboard shortcuts

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