Documentation ¶
Overview ¶
Package logger implements a logging interface used to log messages.
Index ¶
- Constants
- Variables
- func IsInvalidConfig(err error) bool
- type ActivationLoggerConfig
- type Config
- type Logger
- type MicroLogger
- func (l *MicroLogger) Debugf(ctx context.Context, format string, params ...interface{})
- func (l *MicroLogger) Errorf(ctx context.Context, err error, format string, params ...interface{})
- func (l *MicroLogger) Log(keyVals ...interface{})
- func (l *MicroLogger) LogCtx(ctx context.Context, keyVals ...interface{})
- func (l *MicroLogger) With(keyVals ...interface{}) Logger
Constants ¶
const ( KeyLevel = "level" KeyVerbosity = "verbosity" )
Variables ¶
var DefaultCaller = func() interface{} { return fmt.Sprintf("%+v", stack.Caller(4)) }
var DefaultIOWriter = os.Stdout
var DefaultTimestampFormatter = func() interface{} { return time.Now().UTC().Format("2006-01-02T15:04:05.999999-07:00") }
Functions ¶
func IsInvalidConfig ¶
IsInvalidConfig asserts invalidConfigError.
Types ¶
type ActivationLoggerConfig ¶
type Logger ¶
type Logger interface { // Debugf takes a format string and parameters and writes them in debug // level. Debugf(ctx context.Context, format string, params ...interface{}) // Errorf takes an error, a format string and parameters and writes them in // error level. The error stack trace is written as "stack" value log // entry. Errorf(ctx context.Context, err error, format string, params ...interface{}) // Log takes a sequence of alternating key/value pairs which are used // to create the log message structure. Log(keyVals ...interface{}) // LogCtx is the same as Log but additionally taking a context which // may contain additional key-value pairs that are added to the log // issuance, if any. LogCtx(ctx context.Context, keyVals ...interface{}) // With returns a new contextual logger with keyVals appended to those // passed to calls to Log. If logger is also a contextual logger // created by With, keyVals is appended to the existing context. With(keyVals ...interface{}) Logger }
Logger is a simple interface describing services that emit messages to gather certain runtime information.
func NewActivation ¶
func NewActivation(config ActivationLoggerConfig) (Logger, error)
NewActivation creates a new activation key logger. This logger kind can be used on command line tools to improve situations in which log filtering using other command line tools like grep is not sufficient. Due to certain filter mechanisms this Logger implementation should not be used in performance critical applications. The idea of the activation key logger is to have a multi dimensional log filter mechanism. This logger here provides three different features which can be combined and used simultaneously at will.
Filtering arbitrary key-value pairs. The structured nature of the Logger interface expects key-value pairs to be logged. The activation key logger can be configured with any kind of activation key-pairs which, when configured, all have to match against an emitted logging call, in order to be dispatched. In case none, or not all activation keys match, the emitted logging call is going to be ignored. Filtering log levels works using the special log levels debug, info, warning and error. The level based nature of this activation mechanism is that lower log levels match just like exact log levels match. When the Logger is configured to activate on info log levels, the Logger will activate on debug related logs, as well as info related logs, but not on warning or error related logs. Filtering log verbosity works similar like the log level mechanism, but on arbitrary verbosity levels, which are represented as numbers. As long as the configured verbosity is higher or equal to the perceived verbosity obtained by the emitted logging call, the log will be dispatched.
type MicroLogger ¶
type MicroLogger struct {
// contains filtered or unexported fields
}
func New ¶
func New(config Config) (*MicroLogger, error)
func (*MicroLogger) Debugf ¶ added in v0.4.0
func (l *MicroLogger) Debugf(ctx context.Context, format string, params ...interface{})
func (*MicroLogger) Errorf ¶ added in v0.4.0
func (l *MicroLogger) Errorf(ctx context.Context, err error, format string, params ...interface{})
func (*MicroLogger) Log ¶
func (l *MicroLogger) Log(keyVals ...interface{})
func (*MicroLogger) LogCtx ¶
func (l *MicroLogger) LogCtx(ctx context.Context, keyVals ...interface{})
func (*MicroLogger) With ¶
func (l *MicroLogger) With(keyVals ...interface{}) Logger
Directories ¶
Path | Synopsis |
---|---|
Package loggermeta stores and accesses the container struct in context.Context.
|
Package loggermeta stores and accesses the container struct in context.Context. |