zerologfx

package
v0.1.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Module(
	"zerolog", fx.Provide(
		New,
		ToSlog,
		loggingfx.DefaultConfig,
	),
)

Module returns a zerolog constructor and adapters to common loggers

Functions

func Decorator

func Decorator[T any](
	configProvider configfx.Provider[T],
	logger *zerolog.Logger,
) (*zerolog.Logger, error)

Decorator is a fx.Decorate constructor to decorate logger to use settings found in config for all configs implementing [ConfigWithLogging].

The decorator will silently discard any errors since it is only decorating: A user could run version command without providing a valid config path. In such a case config file parsing would fail hence why errors are ignored.

func New

func New(config loggingfx.Config) (*zerolog.Logger, error)

New returns a new configured *zerolog.Logger

func ToFx

func ToFx(log *zerolog.Logger) fxevent.Logger

ToFx provides a logging adapter for logging from fxevent.Logger to zerolog. Designed to be used as a parameter for with fx.WithLogger(). It will rewrite all log levels to debug if other than error.

func ToSlog

func ToSlog(log *zerolog.Logger) *slog.Logger

ToSlog provides a logging adapter for logging from slog to zerolog. Use this whenever something requires slog and you wish to use zerolog instead.

Types

This section is empty.

Jump to

Keyboard shortcuts

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