log

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package log provides structured logging using zerolog. It wraps zerolog to provide a clean API for application-wide logging.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(msg string)

Debug logs a message at debug level using the global logger.

func Debugf

func Debugf(format string, args ...interface{})

Debugf logs a formatted message at debug level using the global logger.

func Error

func Error(msg string)

Error logs a message at error level using the global logger.

func Errorf

func Errorf(format string, args ...interface{})

Errorf logs a formatted message at error level using the global logger.

func Fatal

func Fatal(msg string)

Fatal logs a message at fatal level and exits using the global logger.

func Fatalf

func Fatalf(format string, args ...interface{})

Fatalf logs a formatted message at fatal level and exits using the global logger.

func Info

func Info(msg string)

Info logs a message at info level using the global logger.

func Infof

func Infof(format string, args ...interface{})

Infof logs a formatted message at info level using the global logger.

func InitLogger

func InitLogger(w io.Writer, level zerolog.Level, pretty bool)

InitLogger initializes the global logger with specific configuration. This should be called at application startup.

func ParseLevel

func ParseLevel(level string) zerolog.Level

ParseLevel converts a string level to zerolog.Level.

func SetGlobalLevel

func SetGlobalLevel(level zerolog.Level)

SetGlobalLevel sets the global logging level.

func SetGlobalLogger

func SetGlobalLogger(logger *Logger)

SetGlobalLogger sets the global logger instance.

func Warn

func Warn(msg string)

Warn logs a message at warn level using the global logger.

func Warnf

func Warnf(format string, args ...interface{})

Warnf logs a formatted message at warn level using the global logger.

Types

type Logger

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

Logger wraps zerolog.Logger with application-specific methods.

func New

func New(w io.Writer) *Logger

New creates a new Logger instance with the given writer.

func NewWithLevel

func NewWithLevel(w io.Writer, level zerolog.Level) *Logger

NewWithLevel creates a new Logger with a specific log level.

func WithError

func WithError(err error) *Logger

WithError creates a logger with an error field using the global logger.

func WithField

func WithField(key string, value interface{}) *Logger

WithField creates a logger with an additional field using the global logger.

func WithFields

func WithFields(fields map[string]interface{}) *Logger

WithFields creates a logger with multiple fields using the global logger.

func (*Logger) Debug

func (l *Logger) Debug(msg string)

Debug logs a message at debug level.

func (*Logger) Debugf

func (l *Logger) Debugf(format string, args ...interface{})

Debugf logs a formatted message at debug level.

func (*Logger) Error

func (l *Logger) Error(msg string)

Error logs a message at error level.

func (*Logger) Errorf

func (l *Logger) Errorf(format string, args ...interface{})

Errorf logs a formatted message at error level.

func (*Logger) Fatal

func (l *Logger) Fatal(msg string)

Fatal logs a message at fatal level and exits.

func (*Logger) Fatalf

func (l *Logger) Fatalf(format string, args ...interface{})

Fatalf logs a formatted message at fatal level and exits.

func (*Logger) GetZerolog

func (l *Logger) GetZerolog() *zerolog.Logger

GetZerolog returns the underlying zerolog.Logger for advanced usage.

func (*Logger) Info

func (l *Logger) Info(msg string)

Info logs a message at info level.

func (*Logger) Infof

func (l *Logger) Infof(format string, args ...interface{})

Infof logs a formatted message at info level.

func (*Logger) Warn

func (l *Logger) Warn(msg string)

Warn logs a message at warn level.

func (*Logger) Warnf

func (l *Logger) Warnf(format string, args ...interface{})

Warnf logs a formatted message at warn level.

func (*Logger) With

func (l *Logger) With() *Logger

With creates a child logger with additional fields.

func (*Logger) WithError

func (l *Logger) WithError(err error) *Logger

WithError adds an error field to the logger context.

func (*Logger) WithField

func (l *Logger) WithField(key string, value interface{}) *Logger

WithField adds a field to the logger context.

func (*Logger) WithFields

func (l *Logger) WithFields(fields map[string]interface{}) *Logger

WithFields adds multiple fields to the logger context.

Jump to

Keyboard shortcuts

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