logging

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package logging provides a wrapper around Zerolog.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFieldFilterWriter

func NewFieldFilterWriter(w io.Writer, fieldsToSkip []string) io.Writer

NewFieldFilterWriter creates a new writer that filters out specified fields

func NewLogger

func NewLogger(opts ...LoggerOpt) (*zerolog.Logger, error)

NewLogger creates a new zerolog logger with the requested options

func StoreWriter added in v1.2.0

func StoreWriter(
	ctx context.Context,
	store types.WritableStore,
	clusterName string,
	cloudAccountID string,
) io.Writer

Types

type Attr

type Attr func(zerolog.Context) zerolog.Context

Attr is a custom type to enable dynamic passing of function overloads on the logger to enable for a dynamic list of zerolog attributes onto a logger.

type LoggerOpt

type LoggerOpt = func(logger *internalLogger) error

func WithAttrs

func WithAttrs(attrs ...Attr) LoggerOpt

WithAttrs adds a list of attributes to add to the logger.

Example:

logger := NewLogger(
	WithAttrs(
		func(ctx zerolog.Context) zerolog.Context {
			return ctx.Str("app", "my-application").Int("version", 1)
		},
	),
)

func WithHook

func WithHook(hook zerolog.Hook) LoggerOpt

WithHook attaches a hook to the logger. This can be called multiple times

func WithLevel

func WithLevel(level string) LoggerOpt

WithLevel parses the log level for the logger

func WithSink

func WithSink(sink io.Writer) LoggerOpt

WithSink attaches a sink to the logger. This can be called multiple times

func WithVersion

func WithVersion(version string) LoggerOpt

WithVersion overrides the default version fetched from the `build` library

Directories

Path Synopsis
Package instr provides instrumentation utilities.
Package instr provides instrumentation utilities.
Package logging contains utilities for logging.
Package logging contains utilities for logging.

Jump to

Keyboard shortcuts

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