logger

package
v6.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CtxWithAttrs

func CtxWithAttrs(ctx context.Context, fields ...zap.Field) context.Context

func DPanic

func DPanic(msg string, fields ...zap.Field)

func DPanicContext

func DPanicContext(ctx context.Context, msg string, fields ...zap.Field)

func Debug

func Debug(msg string, fields ...zap.Field)

func DebugContext

func DebugContext(ctx context.Context, msg string, fields ...zap.Field)

func Error

func Error(msg string, fields ...zap.Field)

func ErrorContext

func ErrorContext(ctx context.Context, msg string, fields ...zap.Field)

func Fatal

func Fatal(msg string, fields ...zap.Field)

func FatalContext

func FatalContext(ctx context.Context, msg string, fields ...zap.Field)

func GetCtxFields

func GetCtxFields(ctx context.Context) []zap.Field

GetCtxFields returns key+value from passed context for logger.

func Global

func Global() *zap.Logger

Global returns the process-wide logger. It is always non-nil.

func Info

func Info(msg string, fields ...zap.Field)

func InfoContext

func InfoContext(ctx context.Context, msg string, fields ...zap.Field)

func Init

func Init(level, mode string, opts ...zap.Option) error

Init validates and installs a new process-wide logger. Invalid settings leave the previously installed logger unchanged.

func NewFromConfig

func NewFromConfig(cfg *Config, opts ...zap.Option) *zap.Logger

NewFromConfig installs a logger built from a plain-Go configuration.

It preserves the historical panic-on-invalid-config behavior; prefer Init when configuration errors must be returned to the caller.

func NewFromCtx

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

NewFromCtx creates new logger from context.

func Panic

func Panic(msg string, fields ...zap.Field)

func PanicContext

func PanicContext(ctx context.Context, msg string, fields ...zap.Field)

func RedactDSN

func RedactDSN(dsn string) string

RedactDSN masks credentials in supported connection-string grammars. Inputs that cannot be classified unambiguously never appear in diagnostics.

func SetCtxFields

func SetCtxFields(ctx context.Context, fields ...zap.Field)

SetCtxFields set key+value in passed context for logger.

func Warn

func Warn(msg string, fields ...zap.Field)

func WarnContext

func WarnContext(ctx context.Context, msg string, fields ...zap.Field)

func WithCtxFields

func WithCtxFields(ctx context.Context, fields ...zap.Field) []zap.Field

func WithFields

func WithFields(fields ...zap.Field) *zap.Logger

func WithOptions

func WithOptions(opts ...zap.Option) *zap.Logger

func WrapInCtx

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

WrapInCtx wraps logger in context.

Types

type Config

type Config struct {
	LogMod   LogMod `default:"development" mapstructure:"mod"   validate:"oneof=production development"`
	LogLevel string `default:"debug"       mapstructure:"level" validate:"oneof=debug info warn error fatal"`
}

Config is the plain-Go logger configuration.

type LogMod

type LogMod string

LogMod names a logger output mode.

const (
	DevelopmentMod LogMod = "development"
	ProductionMod  LogMod = "production"
)

func ParseMode

func ParseMode(mode string) (LogMod, error)

ParseMode validates a logger output mode.

type StructLogger

type StructLogger = *zap.Logger

StructLogger is an alias for *zap.Logger included in project structs.

func NewStructLogger

func NewStructLogger(name string) StructLogger

NewStructLogger returns a named child of the process-wide logger.

Jump to

Keyboard shortcuts

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