Documentation
¶
Overview ¶
Package function provides an implementation of the telemetry.Logger interface that uses a given function to emit logs.
Index ¶
- func NewLogger(emitFunc Emit) telemetry.Logger
- type Emit
- type Logger
- func (l *Logger) Clone() telemetry.Logger
- func (l *Logger) Context(ctx context.Context) telemetry.Logger
- func (l *Logger) Debug(msg string, keyValues ...interface{})
- func (l *Logger) Error(msg string, err error, keyValues ...interface{})
- func (l *Logger) Info(msg string, keyValues ...interface{})
- func (l *Logger) Level() telemetry.Level
- func (l *Logger) Metric(m telemetry.Metric) telemetry.Logger
- func (l *Logger) SetLevel(level telemetry.Level)
- func (l *Logger) With(keyValues ...interface{}) telemetry.Logger
- type Values
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Emit ¶
Emit is a function that will be used to produce log messages by the function Logger. Implementations of this function just need to implement the log writing. Decisions on whether to emit a log or not based on the log level should not be made here as the function Logger already takes care of that. Similarly, the keyValues parameter presented in this method will already contain al the key/value pairs that need to be logged. The function will only be called when the log actually needs to be emitted.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is an implementation of the telemetry.Logger that allows configuring named loggers that can be configured independently and referenced by name.
func (*Logger) Context ¶
Context attaches provided Context to the Logger allowing metadata found in this context to be used for log lines and metrics labels.
func (*Logger) Error ¶
Error emits a log message at error level with the given key value pairs. The given error will be used as the last parameter in the message format string.
func (*Logger) Metric ¶
Metric attaches provided Metric to the Logger allowing this metric to record each invocation of Info and Error log lines. If context is available in the Logger, it can be used for Metrics labels.
type Values ¶
type Values struct { // FromContext has all the key/value pairs that have been added to the Logger Context FromContext []interface{} // FromLogger has all the key/value pairs that have been added to the Logger object itself FromLogger []interface{} // FromMethod has the key/value pairs that were passed to the logging method. FromMethod []interface{} }
Values contains all the key/value pairs to be included when emitting logs.