logger

package
v3.13.1 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfiguredLevel added in v3.13.0

func ConfiguredLevel() string

ConfiguredLevel returns the level the process was configured with at startup.

func Level added in v3.13.0

func Level() string

Level returns the current process-wide effective log level name.

func New

func New(opts ...Option) *zerolog.Logger

New creates a new logger.

func ResetLevel added in v3.13.0

func ResetLevel() string

ResetLevel restores the process-wide effective level to the one configured at startup, undoing any runtime SetLevel, and returns that level's name.

func SetLevel added in v3.13.0

func SetLevel(name string) string

SetLevel sets the process-wide effective log level by name, atomically, and returns the canonical level name. Unknown names fall back to info.

Types

type Mode

type Mode string

Mode changes the logging format.

const (
	// JSONMode outputs JSON.
	JSONMode Mode = "json"
	// ConsoleMode outputs human-readable logs.
	ConsoleMode Mode = "console"
)

type Option

type Option func(l *zerolog.Logger)

Option is the option to use to configure the logger.

func WithLevel

func WithLevel(lvl string) Option

WithLevel is an option to configure the logging level.

func WithRuntimeLevel added in v3.13.0

func WithRuntimeLevel(lvl string) Option

WithRuntimeLevel configures the effective level through zerolog's atomic global level, so it can be changed at runtime (see SetLevel) — the Admin API's `logs level` uses this. The logger itself is built at trace, leaving the global level as the only filter. The change is process-wide and in-memory: a restart rebuilds the logger from config and reverts.

func WithWriter

func WithWriter(w io.Writer, m Mode) Option

WithWriter is an option to configure the logging output.

func WithWriterTee added in v3.13.0

func WithWriterTee(w io.Writer, tap io.Writer, m Mode) Option

WithWriterTee is WithWriter with the event's raw JSON also teed to tap (when non-nil), regardless of the primary sink's format.

Jump to

Keyboard shortcuts

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