Documentation ¶
Index ¶
- func NewContext(ctx context.Context, logger *Logger) context.Context
- type Formatter
- type LogLevel
- type Logger
- func (l *Logger) AddContext(key, val string)
- func (l *Logger) Counter(title string)
- func (l *Logger) CounterD(title string, value int, data map[string]interface{})
- func (l *Logger) Critical(title string)
- func (l *Logger) CriticalD(title string, data map[string]interface{})
- func (l *Logger) Debug(title string)
- func (l *Logger) DebugD(title string, data map[string]interface{})
- func (l *Logger) Error(title string)
- func (l *Logger) ErrorD(title string, data map[string]interface{})
- func (l *Logger) GaugeFloat(title string, value float64)
- func (l *Logger) GaugeFloatD(title string, value float64, data map[string]interface{})
- func (l *Logger) GaugeInt(title string, value int)
- func (l *Logger) GaugeIntD(title string, value int, data map[string]interface{})
- func (l *Logger) Info(title string)
- func (l *Logger) InfoD(title string, data map[string]interface{})
- func (l *Logger) SetConfig(source string, logLvl LogLevel, formatter Formatter, output io.Writer)
- func (l *Logger) SetFormatter(formatter Formatter)
- func (l *Logger) SetLogLevel(logLvl LogLevel)
- func (l *Logger) SetOutput(output io.Writer)
- func (l *Logger) Warn(title string)
- func (l *Logger) WarnD(title string, data map[string]interface{})
- type M
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Formatter ¶
Formatter is a function type that takes a map and returns a formatted string with the contents of the map
type LogLevel ¶
type LogLevel int
LogLevel is an enum is used to denote level of logging
Constants used to define different LogLevels supported
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger provides customization of log messages. We can change globals, default log level, formatting, and output destination.
func FromContext ¶
FromContext returns the logger value contained in a context. For convenience, if the context does not contain a logger, a new logger is created and returned. This allows users of this method to use the logger immediately, e.g.
logger.FromContext(ctx).Info("...")
func New ¶
New creates a *logger.Logger. Default values are Debug LogLevel, kayvee Formatter, and std.err output.
func NewWithContext ¶
NewWithContext creates a *logger.Logger. Default values are Debug LogLevel, kayvee Formatter, and std.err output.
func (*Logger) AddContext ¶
AddContext adds or updates a key-val to be logged with all log messages.
func (*Logger) Counter ¶
Counter takes a string and logs with LogLevel = Info, type = counter, and value = 1
func (*Logger) CounterD ¶
CounterD takes a string, value, and data map. It logs with LogLevel = Info, type = counter, and value = value
func (*Logger) GaugeFloat ¶
GaugeFloat takes a string and float value. It logs with LogLevel = Info, type = gauge, and value = value
func (*Logger) GaugeFloatD ¶
GaugeFloatD takes a string, a float value, and data map. It logs with LogLevel = Info, type = gauge, and value = value
func (*Logger) GaugeInt ¶
GaugeInt takes a string and integer value. It logs with LogLevel = Info, type = gauge, and value = value
func (*Logger) GaugeIntD ¶
GaugeIntD takes a string, an integer value, and data map. It logs with LogLevel = Info, type = gauge, and value = value
func (*Logger) SetFormatter ¶
SetFormatter sets the formatter function to use
func (*Logger) SetLogLevel ¶
SetLogLevel sets the default log level threshold