Documentation
¶
Overview ¶
Package consumer provides the functionally to print log events either to console, files, ...
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Aware ¶
type Aware interface {
// GetConsumer returns the current consumer.
GetConsumer() Consumer
}
Aware describes an object that is aware of a Consumer and exports its current state.
type Consumer ¶
type Consumer interface {
// Consume consumes the event.
Consume(event log.Event, source log.CoreLogger)
}
Consumer consumes instances of log.Event of a log.CoreLogger and for example print them to the console, to files, ...
Default is the default instance of Consumer which should cover the majority of all cases.
type Func ¶ added in v0.9.0
type Func func(event log.Event, source log.CoreLogger)
Func is wrapping a given function into an instance of Consumer.
type MutableAware ¶ added in v0.20.0
type MutableAware interface {
Aware
// SetConsumer modifies the current consumer to the given one.
SetConsumer(Consumer)
}
MutableAware is similar to Aware but additionally is able to modify the Consumer by calling SetConsumer(Consumer).
type Recorder ¶ added in v0.10.0
type Recorder struct {
// Synchronized defines if this instance can be used in concurrent
// environments; which is meaningful in the most context. It might have
// additional performance costs.
Synchronized bool
// contains filtered or unexported fields
}
Recorder is an implementation of a Consumer which only records all logged events and makes it able to Get() them afterwards from this Recorder.
func NewRecorder ¶ added in v0.10.0
NewRecorder creates a new instance of Recorder which can be customized using customizer and is ready to use. The created instance is synchronized by default (See Recorder.Synchronized).
func (*Recorder) Consume ¶ added in v0.10.0
func (instance *Recorder) Consume(event log.Event, _ log.CoreLogger)
Consume implements Consumer.Consume()
func (*Recorder) Get ¶ added in v0.10.0
Get return an event at the given index. If this index does not exists this method will panic.
type Writer ¶ added in v0.9.0
type Writer struct {
// Formatter to format the consumed log.Event with. If nothing was provided
// formatter.Default will be used.
Formatter formatter.Formatter
// Interceptor can be used to intercept the consumption of an event shortly
// before the actual consumption or directly afterward. If nothing was
// provided interceptor.Default will be used.
Interceptor interceptor.Interceptor
// HintsProvider is used to determine an instance of hints.Hints for the
// actual log.Event. These might be used by the actual Formatter to know how
// to format the actual log.Event correctly. This could include of
// colorization is supported and demanded or any other stuff. If nothing was
// provided a default instance will be provided which provides:
// 1. hints.ColorsSupport
HintsProvider func(event log.Event, source log.CoreLogger) hints.Hints
// Synchronized defines if this instance can be used in concurrent
// environments; which is meaningful in the most context. It might have
// additional performance costs.
Synchronized bool
// OnFormatError will be called if their as any kind of error while
// formatting an log.Event using the configured Formatter. If nothing was
// provided these errors will result in a fallback message of the event.
OnFormatError func(*Writer, io.Writer, error)
// OnColorInitializationError will be called if their as any kind of error
// while initialize the color support. If nothing was provided these errors
// will be silently swallowed.
OnColorInitializationError func(*Writer, io.Writer, error)
// contains filtered or unexported fields
}
Writer is an implementation of Writer which formats the consumed log.Entry using a configured Formatter and logs it to the configured io.Writer.
NewWriter() is used to create a new instance.
func NewWriter ¶ added in v0.9.0
NewWriter creates a new instance of Writer which can be customized using customizer and is ready to use. The created instance is synchronized by default (See Writer.Synchronized).
func (*Writer) Consume ¶ added in v0.9.0
func (instance *Writer) Consume(event log.Event, source log.CoreLogger)
Consume implements Consumer.Consume()
func (*Writer) GetFormatter ¶ added in v0.20.0
GetFormatter implements formatter.Aware
func (*Writer) GetOut ¶ added in v0.20.0
GetOut returns the actual io.Writer where the output will be written to.
func (*Writer) SetFormatter ¶ added in v0.20.0
SetFormatter implements formatter.MutableAware