observability

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

File: pkg/observability/logger.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLogger

func GetLogger() *zap.Logger

GetLogger returns the initialized global logger instance.

func Initialize

func Initialize(cfg LoggerConfig, consoleWriter zapcore.WriteSyncer)

Initialize sets up the global Zap logger based on configuration and a specified output writer.

func InitializeLogger

func InitializeLogger(cfg LoggerConfig)

InitializeLogger is a convenience wrapper around Initialize for production use.

func ResetForTest

func ResetForTest()

ResetForTest resets the sync.Once and clears the global logger.

func SetLogger

func SetLogger(logger *zap.Logger)

SetLogger is a test helper that forcibly replaces the global logger instance.

func Sync

func Sync()

Sync flushes any buffered log entries.

Types

type ColorConfig added in v0.1.7

type ColorConfig struct {
	Debug  string `mapstructure:"debug" yaml:"debug"`
	Info   string `mapstructure:"info" yaml:"info"`
	Warn   string `mapstructure:"warn" yaml:"warn"`
	Error  string `mapstructure:"error" yaml:"error"`
	DPanic string `mapstructure:"dpanic" yaml:"dpanic"`
	Panic  string `mapstructure:"panic" yaml:"panic"`
	Fatal  string `mapstructure:"fatal" yaml:"fatal"`
}

ColorConfig specifies the terminal color codes for different log levels.

type LoggerConfig added in v0.1.7

type LoggerConfig struct {
	Level       string      `mapstructure:"level" yaml:"level"`
	Format      string      `mapstructure:"format" yaml:"format"`
	AddSource   bool        `mapstructure:"add_source" yaml:"add_source"`
	ServiceName string      `mapstructure:"service_name" yaml:"service_name"`
	LogFile     string      `mapstructure:"log_file" yaml:"log_file"`
	MaxSize     int         `mapstructure:"max_size" yaml:"max_size"`
	MaxBackups  int         `mapstructure:"max_backups" yaml:"max_backups"`
	MaxAge      int         `mapstructure:"max_age" yaml:"max_age"`
	Compress    bool        `mapstructure:"compress" yaml:"compress"`
	Colors      ColorConfig `mapstructure:"colors" yaml:"colors"`
}

LoggerConfig defines all settings related to logging.

Jump to

Keyboard shortcuts

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