logger

package
v0.0.0-...-dc0472d Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultRequestIDKey = "X-Request-ID"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AppLogger

type AppLogger struct {
	// contains filtered or unexported fields
}

AppLogger is a zerolog-based implementation of Logger.

func (*AppLogger) Debug

func (l *AppLogger) Debug() Event

Debug logs a message with debug level.

func (*AppLogger) Error

func (l *AppLogger) Error() Event

Error logs a message with error level.

func (*AppLogger) Fatal

func (l *AppLogger) Fatal() Event

Fatal logs a message with fatal level and exits the program.

func (*AppLogger) Info

func (l *AppLogger) Info() Event

Info logs a message with info level.

func (*AppLogger) WithReqID

func (l *AppLogger) WithReqID(ctx *gin.Context) (Logger, string)

WithReqID returns a logger with request ID using DefaultRequestIDKey.

func (*AppLogger) WithReqIDCustom

func (l *AppLogger) WithReqIDCustom(ctx *gin.Context, identifier string) (Logger, string)

WithReqIDCustom returns a logger with request ID using a custom identifier key.

type Event

type Event interface {
	Str(key, val string) Event
	Int(key string, val int) Event
	Interface(key string, val interface{}) Event
	Dur(key string, val time.Duration) Event
	Err(err error) Event
	Msg(msg string)
	Send()
}

Event defines the interface for log event building with method chaining.

type Logger

type Logger interface {
	Debug() Event
	Info() Event
	Error() Event
	Fatal() Event
	WithReqID(ctx *gin.Context) (Logger, string)
	WithReqIDCustom(ctx *gin.Context, identifier string) (Logger, string)
}

Logger defines the logging interface with method chaining support.

func New

func New(logLevel string, writer io.Writer) Logger

Jump to

Keyboard shortcuts

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