Documentation
¶
Overview ¶
Package zlog provides a simple and flexible logging utility built around the zerolog library.
It offers structured, leveled logging with support for console output, file logging with rotation, and custom output targets. This package simplifies logger setup and management by wrapping zerolog and integrating with the lumberjack package for efficient log file rotation.
Key Features:
- Structured logging using zerolog
- Optional console output with human-readable formatting
- File logging with automatic rotation (size, age, and backup limits)
- Singleton design for easy initialization and global logger access
- Runtime log level adjustments and custom writer support
Example:
package main
import (
"github.com/valentin-kaiser/go-core/zlog"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
)
func main() {
zlog.Logger().
WithConsole().
WithLogFile().
Init("example", zerolog.InfoLevel)
log.Info().Msg("This is an info message")
zlog.SetLevel(zerolog.DebugLevel)
log.Debug().Msg("This is a debug message")
}
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.