logger

package
v0.0.0-...-da72ffe Latest Latest
Warning

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

Go to latest
Published: May 16, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetGlobalLogger

func SetGlobalLogger(l Logger) error

SetGlobalLogger sets the global logger instance. It should be called once during application initialization.

func Sync

func Sync() error

Sync flushes any buffered log entries. It should be called before application exit to ensure all logs are written.

Types

type Logger

type Logger interface {
	Debug(msg string, keysAndValues ...any)
	Info(msg string, keysAndValues ...any)
	Warn(msg string, keysAndValues ...any)
	Error(msg string, keysAndValues ...any)
	Fatal(msg string, keysAndValues ...any)
}

Logger is the interface that wraps basic logging methods.

func CreateLogger

func CreateLogger(nodeId string, cfg config.Logger) (Logger, error)

CreateLogger creates logger instances based on the configuration.

func G

func G() Logger

G retrieves the global logger instance. Returns a no-op logger if no global logger is set.

func InitializeGlobalLogger

func InitializeGlobalLogger(nodeId string, cfg config.Logger) (Logger, error)

InitializeGlobalLogger initializes the global logger based on the provided configuration. It should be called once during application startup.

func NewNoOpLogger

func NewNoOpLogger() Logger

NewNoOpLogger creates a new instance of noOpLogger.

type ZapLogger

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

ZapLogger is an implementation of Logger using Uber's Zap.

func NewZapLogger

func NewZapLogger(nodeId string, cfg config.Logger) (*ZapLogger, error)

NewZapLogger creates a new ZapLogger based on the provided configuration.

func (*ZapLogger) Debug

func (z *ZapLogger) Debug(msg string, keysAndValues ...any)

Debug logs a message at DebugLevel.

func (*ZapLogger) Error

func (z *ZapLogger) Error(msg string, keysAndValues ...any)

Error logs a message at ErrorLevel.

func (*ZapLogger) Fatal

func (z *ZapLogger) Fatal(msg string, keysAndValues ...any)

func (*ZapLogger) Info

func (z *ZapLogger) Info(msg string, keysAndValues ...any)

Info logs a message at InfoLevel.

func (*ZapLogger) Inner

func (z *ZapLogger) Inner() *zap.SugaredLogger

func (*ZapLogger) Warn

func (z *ZapLogger) Warn(msg string, keysAndValues ...any)

Warn logs a message at WarnLevel.

Jump to

Keyboard shortcuts

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