logging

package
v2.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextLogger

func ContextLogger(ctx context.Context, component string) zerolog.Logger

ContextLogger creates a logger with context values. This function uses the global logger configured by Initialize. It adds context values and a component name to the logger.

Parameters:

  • ctx: Context that may contain values to be added to the logger
  • component: Name of the component, added as a field to all log entries

Returns:

  • A zerolog.Logger instance with context and component information

func Initialize

func Initialize(serviceName string, debug bool)

Initialize sets up the zerolog global logger with standard fields. This function should be called once at the start of your application. After calling Initialize, you can use zerolog's log package functions directly (log.Debug(), log.Info(), etc.) or create component-specific loggers with ContextLogger.

Parameters:

  • serviceName: Name of the service, added as a field to all log entries
  • debug: If true, sets log level to Debug, otherwise Info

Types

type LogLevel added in v2.4.9

type LogLevel string

LogLevel represents the logging level

const (
	LogLevelDebug LogLevel = "debug"
	LogLevelInfo  LogLevel = "info"
	LogLevelWarn  LogLevel = "warn"
	LogLevelError LogLevel = "error"
	LogLevelNone  LogLevel = "none"
)

Jump to

Keyboard shortcuts

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