stdzapfx

package
v0.0.23 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package stdzapfx provides an opionated zap logger as an fx dependency.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fx

func Fx() fx.Option

Fx is a convenient option that configures fx to use the zap logger.

func Log added in v0.0.18

func Log(ctx context.Context) *zap.Logger

Log returns a logger from the context or panics if none is available.

func Provide

func Provide() fx.Option

Provide provides the package's components as an fx module.

func TestProvide

func TestProvide(tb zaptest.TestingT) fx.Option

TestProvide provides the package's components as an fx module with a configuration for testing.

func WithLogger added in v0.0.18

func WithLogger(ctx context.Context, logs *zap.Logger) context.Context

WithLogger add a zap logger to the context.

Types

type Config

type Config struct {
	// Level configures the minium logging level that will be captured.
	Level zapcore.Level `env:"LEVEL" envDefault:"info"`
	// Configure the level at which fx logs are shown, default to debug
	FxLevel zapcore.Level `env:"FX_LEVEL" envDefault:"debug"`
	// Outputs configures the zap outputs that will be opened for logging.
	Outputs []string `env:"OUTPUTS" envDefault:"stderr"`
	// Enables console encoding for more developer friendly logging output
	ConsoleEncoding bool `env:"CONSOLE_ENCODING"`
	// DevelopmentEncodingConfig enables encoding useful for developers.
	DevelopmentEncodingConfig bool `env:"DEVELOPMENT_ENCODING_CONFIG"`
}

Config configures the package.

type Params

type Params struct {
	fx.In
	fx.Lifecycle
	Core zapcore.Core
}

Params defines dependencies for creating the module's main component.

type Result

type Result struct {
	fx.Out
	Logger *zap.Logger
}

Result defines the modules main components from our zap module.

func New

func New(params Params) (Result, error)

New constructs the package's components.

Jump to

Keyboard shortcuts

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