logging

package
v0.1.1-alpha Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseLogger

func CloseLogger()

CloseLogger closes current logger's file handles and clears the logger. Call during shutdown to release file descriptors. Safe to call multiple times.

func Debug

func Debug(args ...interface{})

Debug logs a debug message

func Debugf

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

Debugf logs a formatted debug message

func Error

func Error(args ...interface{})

Error logs an error message

func Errorf

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

Errorf logs a formatted error message

func Fatal

func Fatal(args ...interface{})

Fatal logs a fatal message and exits with status code 1. Note: This function calls os.Exit() and cannot be tested in unit tests. Any test attempting to cover this function would terminate the test process.

func Fatalf

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

Fatalf logs a formatted fatal message and exits with status code 1. Note: This function calls os.Exit() and cannot be tested in unit tests. Any test attempting to cover this function would terminate the test process.

func GetLogger

func GetLogger() *logrus.Logger

GetLogger returns the current logger instance (deprecated: use L() instead) This function is kept for backward compatibility but L() is preferred.

func Info

func Info(args ...interface{})

Info logs an info message

func Infof

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

Infof logs a formatted info message

func InitLogger

func InitLogger(cfg *Config) error

InitLogger initializes or reloads the global logger based on configuration. It atomically swaps in the new logger and closes previous file handles to prevent leaks. This function is safe to call multiple times for config reloading.

func L

func L() *logrus.Logger

L returns the current logger instance. Callers should NOT cache the returned pointer across config reloads; instead, call logging.L() when you need to log. This ensures you always get the current logger after config reloads.

func Warn

func Warn(args ...interface{})

Warn logs a warning message

func Warnf

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

Warnf logs a formatted warning message

func WithField

func WithField(key string, value interface{}) *logrus.Entry

WithField returns a logger with a single field

func WithFields

func WithFields(fields logrus.Fields) *logrus.Entry

WithFields returns a logger with multiple fields

Types

type Config

type Config struct {
	Level  string `yaml:"level"`  // debug, info, warn, error
	Format string `yaml:"format"` // text, json
	Output string `yaml:"output"` // stdout, file path, or "stdout,/path/to/file.log"
}

Config represents logging configuration

Jump to

Keyboard shortcuts

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