zlog

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2025 License: BSD-3-Clause Imports: 9 Imported by: 0

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

func Logger

func Logger() *logger

Logger returns the singleton instance of the logger.

Types

This section is empty.

Jump to

Keyboard shortcuts

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