logger

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: LGPL-2.1 Imports: 23 Imported by: 0

README

mod/logger

mod/logger builds the process logger from configuration. It wires console output, rotating file output, and optional VictoriaLogs shipping into one logger used by runtime packages.

Place in the runtime

flowchart TB
  config["stconf config"] --> logger["mod/logger"]
  logger --> console["console sink"]
  logger --> file["rotating file sink"]
  logger --> remote["VictoriaLogs sink"]
  runtime["runtime packages"] --> logger

Responsibilities

  • Build a structured logger from logging.* config.
  • Normalize sink levels and disabled sinks.
  • Configure log file rotation limits.
  • Keep user-facing log messages in English.
  • Provide a no-surprise logger for startup, runtime, and maintenance commands.

Contracts

  • Logger construction should not start the main runtime.
  • A disabled sink must not allocate background workers.
  • Remote logging failures must not crash the mirror. They are operational degradation, not data corruption.
  • Logs should use stable, low-cardinality fields such as component, key, version, and request id.

Important files

  • obj.go: logger construction and sink selection.
  • helper.go: sink helpers and level parsing.
  • victorialogs.go: VictoriaLogs sink delivery.

Operational notes

Use file logging for persistent node diagnostics. Console logging is usually enough for containers. VictoriaLogs is optional and should be treated as best-effort telemetry.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Obj

type Obj struct {
	// contains filtered or unexported fields
}

Obj is the assembled logger: zerolog value, closeable sinks, and optional VictoriaLogs sink reference.

func New

func New(configObj *stcfg.ConfigObj) (*Obj, error)

New builds a multiplexed zerolog from enabled sinks; the effective level is the minimum sink level. It fails when no sink is enabled.

func (*Obj) Close

func (obj *Obj) Close() error

Close closes all sinks exactly once and is safe on a nil receiver.

func (*Obj) RegisterMetrics

func (obj *Obj) RegisterMetrics(meterObj metric.Meter) error

RegisterMetrics publishes VictoriaLogs delivery counters.

func (*Obj) XErr

func (obj *Obj) XErr(err error) *zerolog.Event

XErr expands stcode errors into structured events with their fields; other errors use Error.Err.

func (*Obj) Zero

func (obj *Obj) Zero() *zerolog.Logger

Zero returns the underlying zerolog.Logger for structured logging.

Jump to

Keyboard shortcuts

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