Documentation ¶
Index ¶
- func NewContext(ctx context.Context, logger KayveeLogger) context.Context
- func SetGlobalRouting(filename string) error
- type Formatter
- type KayveeLogger
- 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) SetRouter(router router.Router)
- func (l *Logger) Warn(title string)
- func (l *Logger) WarnD(title string, data map[string]interface{})
- type M
- type MockRouteCountLogger
- func (ml *MockRouteCountLogger) AddContext(key, val string)
- func (ml *MockRouteCountLogger) Counter(title string)
- func (ml *MockRouteCountLogger) CounterD(title string, value int, data map[string]interface{})
- func (ml *MockRouteCountLogger) Critical(title string)
- func (ml *MockRouteCountLogger) CriticalD(title string, data map[string]interface{})
- func (ml *MockRouteCountLogger) Debug(title string)
- func (ml *MockRouteCountLogger) DebugD(title string, data map[string]interface{})
- func (ml *MockRouteCountLogger) Error(title string)
- func (ml *MockRouteCountLogger) ErrorD(title string, data map[string]interface{})
- func (ml *MockRouteCountLogger) GaugeFloat(title string, value float64)
- func (ml *MockRouteCountLogger) GaugeFloatD(title string, value float64, data map[string]interface{})
- func (ml *MockRouteCountLogger) GaugeInt(title string, value int)
- func (ml *MockRouteCountLogger) GaugeIntD(title string, value int, data map[string]interface{})
- func (ml *MockRouteCountLogger) Info(title string)
- func (ml *MockRouteCountLogger) InfoD(title string, data map[string]interface{})
- func (ml *MockRouteCountLogger) RuleCounts() map[string]int
- func (ml *MockRouteCountLogger) SetConfig(source string, logLvl LogLevel, formatter Formatter, output io.Writer)
- func (ml *MockRouteCountLogger) SetFormatter(formatter Formatter)
- func (ml *MockRouteCountLogger) SetLogLevel(logLvl LogLevel)
- func (ml *MockRouteCountLogger) SetOutput(output io.Writer)
- func (ml *MockRouteCountLogger) SetRouter(router router.Router)
- func (ml *MockRouteCountLogger) Warn(title string)
- func (ml *MockRouteCountLogger) WarnD(title string, data map[string]interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewContext ¶
func NewContext(ctx context.Context, logger KayveeLogger) context.Context
NewContext creates a new context object containing a logger value.
func SetGlobalRouting ¶
SetGlobalRouting installs a new log router onto the KayveeLogger with the configuration specified in `filename`. For convenience, the KayveeLogger is expected to return itself as the first return value.
Types ¶
type Formatter ¶
Formatter is a function type that takes a map and returns a formatted string with the contents of the map
type KayveeLogger ¶
type KayveeLogger interface { // AddContext adds a new key-val to be logged with all log messages. AddContext(key, val string) // SetConfig allows configuration changes in one go SetConfig(source string, logLvl LogLevel, formatter Formatter, output io.Writer) // SetFormatter sets the formatter function to use SetFormatter(formatter Formatter) // SetLogLevel sets the default log level threshold SetLogLevel(logLvl LogLevel) // SetOutput changes the output destination of the logger SetOutput(output io.Writer) // SetRouter changes the router for this logger instance. Once set, logs produced by this // logger will not be touched by the global router. Mostly used for testing and benchmarking. SetRouter(router router.Router) // Counter takes a string and logs with LogLevel = Info Counter(title string) // CounterD takes a string, value, and data map. It logs with LogLevel = Info CounterD(title string, value int, data map[string]interface{}) // Critical takes a string and logs with LogLevel = Critical Critical(title string) // CriticalD takes a string and data map. It logs with LogLevel = Critical CriticalD(title string, data map[string]interface{}) // Debug takes a string and logs with LogLevel = Debug Debug(title string) // DebugD takes a string and data map. It logs with LogLevel = Debug DebugD(title string, data map[string]interface{}) // Error takes a string and logs with LogLevel = Error Error(title string) // ErrorD takes a string and data map. It logs with LogLevel = Error ErrorD(title string, data map[string]interface{}) // GaugeFloat takes a string and float value. It logs with LogLevel = Info GaugeFloat(title string, value float64) // GaugeFloatD takes a string, a float value, and data map. It logs with LogLevel = Info GaugeFloatD(title string, value float64, data map[string]interface{}) // GaugeInt takes a string and integer value. It logs with LogLevel = Info GaugeInt(title string, value int) // GaugeIntD takes a string, an integer value, and data map. It logs with LogLevel = Info GaugeIntD(title string, value int, data map[string]interface{}) // Info takes a string and logs with LogLevel = Info Info(title string) // InfoD takes a string and data map. It logs with LogLevel = Info InfoD(title string, data map[string]interface{}) // Warn takes a string and logs with LogLevel = Warning Warn(title string) // WarnD takes a string and data map. It logs with LogLevel = Warning WarnD(title string, data map[string]interface{}) // contains filtered or unexported methods }
KayveeLogger is the main logging interface, providing customization of log messages.
func FromContext ¶
func FromContext(ctx context.Context) KayveeLogger
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 ¶
func New(source string) KayveeLogger
New creates a *logger.Logger. Default values are Debug LogLevel, kayvee Formatter, and std.err output.
func NewWithContext ¶
func NewWithContext(source string, contextValues map[string]interface{}) KayveeLogger
NewWithContext creates a *logger.Logger. Default values are Debug LogLevel, kayvee Formatter, and std.err output.
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 is the default implementation of KayveeLogger. It provides customization of globals, default log level, formatting, and output destination.
func (*Logger) AddContext ¶
AddContext implements the method for the KayveeLogger interface.
func (*Logger) Counter ¶
Counter implements the method for the KayveeLogger interface. Logs with type = gauge, and value = value
func (*Logger) CounterD ¶
CounterD implements the method for the KayveeLogger interface. Logs with type = gauge, and value = value
func (*Logger) GaugeFloat ¶
GaugeFloat implements the method for the KayveeLogger interface. Logs with type = gauge, and value = value
func (*Logger) GaugeFloatD ¶
GaugeFloatD implements the method for the KayveeLogger interface. Logs with type = gauge, and value = value
func (*Logger) GaugeInt ¶
GaugeInt implements the method for the KayveeLogger interface. Logs with type = gauge, and value = value
func (*Logger) GaugeIntD ¶
GaugeIntD implements the method for the KayveeLogger interface. Logs with type = gauge, and value = value
func (*Logger) SetFormatter ¶
SetFormatter implements the method for the KayveeLogger interface.
func (*Logger) SetLogLevel ¶
SetLogLevel implements the method for the KayveeLogger interface.
type MockRouteCountLogger ¶
type MockRouteCountLogger struct {
// contains filtered or unexported fields
}
MockRouteCountLogger is a mock implementation of KayveeLogger that counts the router rules applied to each log call without actually formatting or writing the log line.
func NewMockCountLogger ¶
func NewMockCountLogger(source string) *MockRouteCountLogger
NewMockCountLogger returns a new MockRoutCountLogger with the specified `source`.
func NewMockCountLoggerWithContext ¶
func NewMockCountLoggerWithContext(source string, contextValues map[string]interface{}) *MockRouteCountLogger
NewMockCountLoggerWithContext returns a new MockRoutCountLogger with the specified `source` and `contextValues`.
func (*MockRouteCountLogger) AddContext ¶
func (ml *MockRouteCountLogger) AddContext(key, val string)
AddContext implements the method for the KayveeLogger interface.
func (*MockRouteCountLogger) Counter ¶
func (ml *MockRouteCountLogger) Counter(title string)
Counter implements the method for the KayveeLogger interface.
func (*MockRouteCountLogger) CounterD ¶
func (ml *MockRouteCountLogger) CounterD(title string, value int, data map[string]interface{})
CounterD implements the method for the KayveeLogger interface.
func (*MockRouteCountLogger) Critical ¶
func (ml *MockRouteCountLogger) Critical(title string)
Critical implements the method for the KayveeLogger interface.
func (*MockRouteCountLogger) CriticalD ¶
func (ml *MockRouteCountLogger) CriticalD(title string, data map[string]interface{})
CriticalD implements the method for the KayveeLogger interface.
func (*MockRouteCountLogger) Debug ¶
func (ml *MockRouteCountLogger) Debug(title string)
Debug implements the method for the KayveeLogger interface.
func (*MockRouteCountLogger) DebugD ¶
func (ml *MockRouteCountLogger) DebugD(title string, data map[string]interface{})
DebugD implements the method for the KayveeLogger interface.
func (*MockRouteCountLogger) Error ¶
func (ml *MockRouteCountLogger) Error(title string)
Error implements the method for the KayveeLogger interface.
func (*MockRouteCountLogger) ErrorD ¶
func (ml *MockRouteCountLogger) ErrorD(title string, data map[string]interface{})
ErrorD implements the method for the KayveeLogger interface.
func (*MockRouteCountLogger) GaugeFloat ¶
func (ml *MockRouteCountLogger) GaugeFloat(title string, value float64)
GaugeFloat implements the method for the KayveeLogger interface.
func (*MockRouteCountLogger) GaugeFloatD ¶
func (ml *MockRouteCountLogger) GaugeFloatD(title string, value float64, data map[string]interface{})
GaugeFloatD implements the method for the KayveeLogger interface. Logs with type = gauge, and value = value
func (*MockRouteCountLogger) GaugeInt ¶
func (ml *MockRouteCountLogger) GaugeInt(title string, value int)
GaugeInt implements the method for the KayveeLogger interface.
func (*MockRouteCountLogger) GaugeIntD ¶
func (ml *MockRouteCountLogger) GaugeIntD(title string, value int, data map[string]interface{})
GaugeIntD implements the method for the KayveeLogger interface.
func (*MockRouteCountLogger) Info ¶
func (ml *MockRouteCountLogger) Info(title string)
Info implements the method for the KayveeLogger interface.
func (*MockRouteCountLogger) InfoD ¶
func (ml *MockRouteCountLogger) InfoD(title string, data map[string]interface{})
InfoD implements the method for the KayveeLogger interface.
func (*MockRouteCountLogger) RuleCounts ¶
func (ml *MockRouteCountLogger) RuleCounts() map[string]int
RuleCounts returns a map of rule names to the number of times that rule has been applied in routing logs for MockRouteCountLogger. Only includes routing rules that have at least one use.
func (*MockRouteCountLogger) SetConfig ¶
func (ml *MockRouteCountLogger) SetConfig(source string, logLvl LogLevel, formatter Formatter, output io.Writer)
SetConfig implements the method for the KayveeLogger interface.
func (*MockRouteCountLogger) SetFormatter ¶
func (ml *MockRouteCountLogger) SetFormatter(formatter Formatter)
SetFormatter implements the method for the KayveeLogger interface.
func (*MockRouteCountLogger) SetLogLevel ¶
func (ml *MockRouteCountLogger) SetLogLevel(logLvl LogLevel)
SetLogLevel implements the method for the KayveeLogger interface.
func (*MockRouteCountLogger) SetOutput ¶
func (ml *MockRouteCountLogger) SetOutput(output io.Writer)
SetOutput implements the method for the KayveeLogger interface.
func (*MockRouteCountLogger) SetRouter ¶
func (ml *MockRouteCountLogger) SetRouter(router router.Router)
SetRouter implements the method for the KayveeLogger interface.
func (*MockRouteCountLogger) Warn ¶
func (ml *MockRouteCountLogger) Warn(title string)
Warn implements the method for the KayveeLogger interface.
func (*MockRouteCountLogger) WarnD ¶
func (ml *MockRouteCountLogger) WarnD(title string, data map[string]interface{})
WarnD implements the method for the KayveeLogger interface.