logger

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger struct {
	*zap.Logger
}

Logger wraps zap.Logger to provide a consistent interface.

func New

func New(level string, serviceName string) (*Logger, error)

New creates a new logger based on the provided level and service name. level: debug, info, warn, error, dpanic, panic, fatal. serviceName: name of the service for logging context.

func (*Logger) Error

func (l *Logger) Error(ctx context.Context, msg string, err error, fields map[string]any)

Error logs an error message with context, associated error, and fields.

func (*Logger) Info

func (l *Logger) Info(ctx context.Context, msg string, fields map[string]any)

Info logs an informational message with context and fields.

func (*Logger) Sugar

func (l *Logger) Sugar() *zap.SugaredLogger

Sugar returns a SugaredLogger for less verbose logging.

func (*Logger) SugarWith

func (l *Logger) SugarWith(fields ...zap.Field) *zap.SugaredLogger

SugarWith returns a SugaredLogger with additional fields.

func (*Logger) With

func (l *Logger) With(fields ...zap.Field) *Logger

With creates a child logger with additional fields. This is useful for adding context-specific fields like request_id, trace_id, etc.

Jump to

Keyboard shortcuts

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