-- import "github.com/Clever/kayvee-go/v7/logger"
type Formatter func(data map[string]interface{}) string
Formatter is a function type that takes a map and returns a formatted string with the contents of the map
type LogLevel int
LogLevel is an enum is used to denote level of logging
const (
Debug LogLevel = iota
Info
Warning
Error
Critical
)
Constants used to define different LogLevels supported
func (l LogLevel) String() string
type Logger struct {
}
Logger provides customization of log messages. We can change globals, default log level, formatting, and output destination.
func New(source string) *Logger
New creates a *logger.Logger. Default values are Debug LogLevel, kayvee Formatter, and std.err output.
func (l *Logger) Counter(title string)
Counter takes a string and logs with LogLevel = Info, type = counter, and value = 1
func (l *Logger) CounterD(title string, value int, data map[string]interface{})
CounterD takes a string, value, and data map. It logs with LogLevel = Info, type = counter, and value = value
func (l *Logger) Critical(title string)
Critical takes a string and logs with LogLevel = Critical
func (l *Logger) CriticalD(title string, data map[string]interface{})
CriticalD takes a string and data map. It logs with LogLevel = Critical
func (l *Logger) Debug(title string)
Debug takes a string and logs with LogLevel = Debug
func (l *Logger) DebugD(title string, data map[string]interface{})
DebugD takes a string and data map. It logs with LogLevel = Debug
func (l *Logger) Error(title string)
Error takes a string and logs with LogLevel = Error
func (l *Logger) ErrorD(title string, data map[string]interface{})
ErrorD takes a string and data map. It logs with LogLevel = Error
func (l *Logger) GaugeFloat(title string, value float64)
GaugeFloat takes a string and float value. It logs with LogLevel = Info, type = gauge, and value = value
func (l *Logger) GaugeFloatD(title string, value float64, data map[string]interface{})
GaugeFloatD takes a string, a float value, and data map. It logs with LogLevel = Info, type = gauge, and value = value
func (l *Logger) GaugeInt(title string, value int)
GaugeInt takes a string and integer value. It logs with LogLevel = Info, type = gauge, and value = value
func (l *Logger) GaugeIntD(title string, value int, data map[string]interface{})
GaugeIntD takes a string, an integer value, and data map. It logs with LogLevel = Info, type = gauge, and value = value
func (l *Logger) Info(title string)
Info takes a string and logs with LogLevel = Info
func (l *Logger) InfoD(title string, data map[string]interface{})
InfoD takes a string and data map. It logs with LogLevel = Info
func (l *Logger) SetConfig(source string, logLvl LogLevel, formatter Formatter, output io.Writer)
SetConfig allows configuration changes in one go
func (l *Logger) SetFormatter(formatter Formatter)
SetFormatter sets the formatter function to use
func (l *Logger) SetLogLevel(logLvl LogLevel)
SetLogLevel sets the default log level threshold
func (l *Logger) SetOutput(output io.Writer)
SetOutput changes the output destination of the logger
func (l *Logger) Warn(title string)
Warn takes a string and logs with LogLevel = Warning
func (l *Logger) WarnD(title string, data map[string]interface{})
WarnD takes a string and data map. It logs with LogLevel = Warning
type M map[string]interface{}