Documentation
¶
Overview ¶
Package utility provides utility functions and types for the application, such as logging.
Index ¶
- type Logger
- func (l *Logger) Debug(keyvals ...any)
- func (l *Logger) Err(err error, keyvals ...any)
- func (l *Logger) Error(keyvals ...any)
- func (l *Logger) GetLogger() log.Logger
- func (l *Logger) Info(keyvals ...any)
- func (l *Logger) Log(keyvals ...any)
- func (l *Logger) SetDebug(value bool) *Logger
- func (l *Logger) Warn(keyvals ...any)
- func (l *Logger) With(keyvals ...any) *Logger
- func (l *Logger) WithPrefix(keyvals ...any) *Logger
- type LoggerFormat
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is a wrapper around go-kit log.Logger that provides structured logging with different levels.
func NewLogger ¶
func NewLogger(format LoggerFormat, debug bool) *Logger
NewLogger creates a new Logger with the specified format and debug level.
func (*Logger) SetDebug ¶
SetDebug sets the debug level for the logger. If debug is true, debug messages will be logged.
func (*Logger) With ¶
With returns a new contextual logger with keyvals prepended to those passed to calls to Log. If logger is also a contextual logger created by With or WithPrefix, keyvals is appended to the existing context.
The returned Logger replaces all value elements (odd indexes) containing a Valuer with their generated value for each call to its Log method.
func (*Logger) WithPrefix ¶
WithPrefix returns a new contextual logger with keyvals prepended to those passed to calls to Log. If logger is also a contextual logger created by With or WithPrefix, keyvals is prepended to the existing context.
The returned Logger replaces all value elements (odd indexes) containing a Valuer with their generated value for each call to its Log method.
type LoggerFormat ¶
type LoggerFormat string
LoggerFormat represents the format of the logs.
const ( // LogFormatJSON represents the JSON log format. LogFormatJSON LoggerFormat = "json" // LogFormatFmt represents the logfmt log format. LogFormatFmt LoggerFormat = "fmt" )