logging

package
v0.0.0-...-c407d37 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildZapConfig

func BuildZapConfig(opts ...ZapConfigOption) zap.Config

BuildZapConfig generates the zap Config

func Config

func Config(opts ...ZapConfigOption) (*zap.Logger, func(), error)

Config configures a Zap logger based on the environment string and debugLevel

func FromContext

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

FromContext returns a logger associated with a context. If the context has no logger, the global logger is returned

func FromContextWithoutDefault

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

FromContextWithoutDefault returns a logger associated with a context. If the context has no logger, nil is returned

func NewContext

func NewContext(ctx context.Context, logger *zap.Logger) context.Context

NewContext returns a new context with a logger.

Types

type ZapConfig

type ZapConfig struct {
	Environment      string
	LoggingLevel     string
	StacktraceLength int
}

ZapConfig defines the configurable parameters you can pass in when setting up the logger. See examples where we call logging.Config

type ZapConfigOption

type ZapConfigOption func(*ZapConfig)

ZapConfigOption is the type for the possible options you can pass in to logging.Config

func WithEnvironment

func WithEnvironment(environment string) ZapConfigOption

WithEnvironment provides an option to pass in the environment

func WithLoggingLevel

func WithLoggingLevel(level string) ZapConfigOption

WithLoggingLevel provides an option to pass in the logging level

func WithStacktraceLength

func WithStacktraceLength(length int) ZapConfigOption

WithStacktraceLength provides an option to pass in the stack trace length

Jump to

Keyboard shortcuts

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