log

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddFlags

func AddFlags(v *viper.Viper, f *pflag.FlagSet)

func LoggerFromContext

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

LoggerFromContext returns a logger from the given context with the default namespace tags attached to it

func LoggerWithFieldsFromContext

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

LoggerWithFieldsFromContext returns a logger from the given context with the default namespace tags attached to it

func LoggerWithFieldsFromNamespaceContext

func LoggerWithFieldsFromNamespaceContext(ctx context.Context, namespaces ...string) *zap.Logger

LoggerWithFieldsFromNamespaceContext returns a logger from the given context. It loads the tags from the provided tags namespace and adds them to the logger.

func NewLogger

func NewLogger(level Level, format Format) (*zap.Logger, error)

NewLogger creates a new logger with the given log level and format.

func TagsToFields

func TagsToFields(tags []*tag.Tag) []zap.Field

TagsToFields converts a slice of tags to zap fields

func WithLogger

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

WithLogger returns a new context with the given logger attached to it

Types

type Format

type Format int
const (
	TextFormat Format = iota
	JSONFormat
)

func ParseFormat

func ParseFormat(format string) (Format, error)

type Level

type Level int
const (
	DebugLevel Level = iota
	InfoLevel
	WarnLevel
	ErrorLevel
)

func ParseLevel

func ParseLevel(level string) (Level, error)

Jump to

Keyboard shortcuts

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