logging

package
v1.0.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(message string, fields ...map[string]interface{})

Debug logs a debug message using the global logger

func Debugf

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

Debugf logs a formatted debug message using the global logger

func Error

func Error(message string, fields ...map[string]interface{})

Error logs an error message using the global logger

func Errorf

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

Errorf logs a formatted error message using the global logger

func Info

func Info(message string, fields ...map[string]interface{})

Info logs an info message using the global logger

func Infof

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

Infof logs a formatted info message using the global logger

func SetGlobalLogger

func SetGlobalLogger(logger *Logger)

SetGlobalLogger sets the global logger instance

func Warn

func Warn(message string, fields ...map[string]interface{})

Warn logs a warning message using the global logger

func Warnf

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

Warnf logs a formatted warning message using the global logger

Types

type FieldLogger

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

FieldLogger is a logger with predefined fields

func (*FieldLogger) Debug

func (fl *FieldLogger) Debug(message string)

Debug logs a debug message with predefined fields

func (*FieldLogger) Debugf

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

Debugf logs a formatted debug message with predefined fields

func (*FieldLogger) Error

func (fl *FieldLogger) Error(message string)

Error logs an error message with predefined fields

func (*FieldLogger) Errorf

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

Errorf logs a formatted error message with predefined fields

func (*FieldLogger) Info

func (fl *FieldLogger) Info(message string)

Info logs an info message with predefined fields

func (*FieldLogger) Infof

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

Infof logs a formatted info message with predefined fields

func (*FieldLogger) Warn

func (fl *FieldLogger) Warn(message string)

Warn logs a warning message with predefined fields

func (*FieldLogger) Warnf

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

Warnf logs a formatted warning message with predefined fields

type LogLevel

type LogLevel int

LogLevel represents the severity level of a log message

const (
	LevelDebug LogLevel = iota
	LevelInfo
	LevelWarn
	LevelError
)

func ParseLogLevel

func ParseLogLevel(level string) (LogLevel, error)

ParseLogLevel parses a string into a LogLevel

func (LogLevel) String

func (l LogLevel) String() string

String returns the string representation of the log level

type Logger

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

Logger represents a structured logger

func GetGlobalLogger

func GetGlobalLogger() *Logger

GetGlobalLogger returns the global logger instance

func NewConsoleLogger

func NewConsoleLogger(verbose, quiet bool) *Logger

NewConsoleLogger creates a logger that writes to stdout/stderr

func NewFileLogger

func NewFileLogger(filename string, level LogLevel) (*Logger, error)

NewFileLogger creates a logger that writes to a file

func NewLogger

func NewLogger(level LogLevel, output io.Writer, quiet bool) *Logger

NewLogger creates a new logger instance

func NewMultiLogger

func NewMultiLogger(loggers ...*Logger) *Logger

NewMultiLogger creates a logger that writes to multiple outputs

func (*Logger) Debug

func (l *Logger) Debug(message string, fields ...map[string]interface{})

Debug logs a debug message

func (*Logger) Debugf

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

Debugf logs a formatted debug message

func (*Logger) Error

func (l *Logger) Error(message string, fields ...map[string]interface{})

Error logs an error message

func (*Logger) Errorf

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

Errorf logs a formatted error message

func (*Logger) Info

func (l *Logger) Info(message string, fields ...map[string]interface{})

Info logs an info message

func (*Logger) Infof

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

Infof logs a formatted info message

func (*Logger) IsEnabled

func (l *Logger) IsEnabled(level LogLevel) bool

IsEnabled checks if a log level is enabled

func (*Logger) SetLevel

func (l *Logger) SetLevel(level LogLevel)

SetLevel sets the minimum log level

func (*Logger) Warn

func (l *Logger) Warn(message string, fields ...map[string]interface{})

Warn logs a warning message

func (*Logger) Warnf

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

Warnf logs a formatted warning message

func (*Logger) WithFields

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

WithFields creates a new logger with additional fields

Jump to

Keyboard shortcuts

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