Documentation
¶
Overview ¶
Package logger provides a structured logging wrapper around go.uber.org/zap.
The logger is initialized with sensible defaults (JSON output, ISO8601 timestamps, Info level) and can be configured via environment variables or programmatically.
Usage:
import "bitbucket.org/jbjoret/commons/logger"
// Initialize from environment (optional, reads LOG_LEVEL env var)
logger.Init()
// Log messages
logger.Info("Application started", zap.String("version", "1.0"))
logger.Debug("Debug information", zap.Int("count", 42))
logger.Error("Something went wrong", zap.Error(err))
// Change log level programmatically
logger.SetLogLevel("debug")
// Get current log level
level := logger.GetLogLevel()
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Init ¶
func Init()
Init initializes the logger's level from the environment. It should be called after loading the .env file.
func SetLogLevel ¶
SetLogLevel sets the log level based on a string.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.