Documentation ¶
Overview ¶
Interceptors are used to intercept instances of log.Event that are requested to be logged. It can modify events (before they get logged) or even fully prevents to get logged.
Index ¶
- type Fatal
- type Interceptor
- type Interceptors
- func (instance *Interceptors) Add(v Interceptor) *Interceptors
- func (instance Interceptors) GetPriority() int16
- func (instance Interceptors) Len() int
- func (instance Interceptors) Less(i, j int) bool
- func (instance Interceptors) OnAfterLog(event log.Event, provider log.Provider) (canContinue bool)
- func (instance Interceptors) OnBeforeLog(event log.Event, provider log.Provider) (intercepted log.Event)
- func (instance Interceptors) Swap(i, j int)
- type OnAfterLogFunc
- type OnBeforeLogFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Fatal ¶
type Fatal struct { // ExitCode to exit the application with. ExitCode int }
Fatal will exit the application after logged events on level.Fatal.
func (*Fatal) GetPriority ¶ added in v0.9.0
GetPriority implements Interceptor.GetPriority()
func (*Fatal) OnAfterLog ¶
OnAfterLog implements Interceptor.OnAfterLog()
type Interceptor ¶
type Interceptor interface { // OnBeforeLog is called shortly before a log.Event should be logged. // Whatever is returned by this method will be logged (if not nil). If this // method returns nil logging of this event will be skipped and calling of // other interceptors will be skipped, too. OnBeforeLog(log.Event, log.Provider) (intercepted log.Event) // OnAfterLog is called shortly after a log.Event was logged. If canContinue // is false no other Interceptor will be called afterwards. OnAfterLog(log.Event, log.Provider) (canContinue bool) // GetPriority defines the order how all interceptors will be called. As // lower this value is, as earlier this Interceptor will be called. GetPriority() int16 }
Interceptor is used to intercept instances of log.Event that are requested to be logged. It can modify events (before they get logged) or even fully prevents to get logged.
func NewFacade ¶ added in v0.9.0
func NewFacade(provider func() Interceptor) Interceptor
NewFacade creates a facade of Interceptor using the given provider.
type Interceptors ¶
type Interceptors []Interceptor
Interceptors is a collection of several interceptors.
Add() should be used to modify this instance because it will ensure the correct order of all interceptors when this one is called.
var Default Interceptors = Interceptors{}
Default is the default instance of Interceptors which should cover the most of the cases.
func (*Interceptors) Add ¶ added in v0.4.0
func (instance *Interceptors) Add(v Interceptor) *Interceptors
Add appends a given Interceptor to this instance and ensures that everything inside is ordered according to Interceptor.GetPriority().
func (Interceptors) GetPriority ¶ added in v0.4.0
func (instance Interceptors) GetPriority() int16
GetPriority implements Interceptor.GetPriority() and will return the lowest priority of all contained interceptors.
func (Interceptors) Len ¶ added in v0.4.0
func (instance Interceptors) Len() int
Len provides the length of this instance.
func (Interceptors) Less ¶ added in v0.4.0
func (instance Interceptors) Less(i, j int) bool
Less reports whether the element with index i should sort before the element with index j.
func (Interceptors) OnAfterLog ¶
OnAfterLog implements Interceptor.OnAfterLog()
func (Interceptors) OnBeforeLog ¶
func (instance Interceptors) OnBeforeLog(event log.Event, provider log.Provider) (intercepted log.Event)
OnBeforeLog implements Interceptor.OnBeforeLog()
func (Interceptors) Swap ¶ added in v0.4.0
func (instance Interceptors) Swap(i, j int)
Swap swaps the elements with indexes i and j.
type OnAfterLogFunc ¶ added in v0.9.0
OnAfterLogFunc is a shortcut to Interceptor.OnAfterLog().
func (OnAfterLogFunc) GetPriority ¶ added in v0.9.0
func (instance OnAfterLogFunc) GetPriority() int16
GetPriority implements Interceptor.GetPriority().
func (OnAfterLogFunc) OnAfterLog ¶ added in v0.9.0
OnAfterLog implements Interceptor.OnAfterLog().
func (OnAfterLogFunc) OnBeforeLog ¶ added in v0.9.0
OnBeforeLog implements Interceptor.OnBeforeLog().
type OnBeforeLogFunc ¶ added in v0.9.0
OnBeforeLogFunc is a shortcut to Interceptor.OnBeforeLog().
func (OnBeforeLogFunc) GetPriority ¶ added in v0.9.0
func (instance OnBeforeLogFunc) GetPriority() int16
GetPriority implements Interceptor.GetPriority().
func (OnBeforeLogFunc) OnAfterLog ¶ added in v0.9.0
OnAfterLog implements Interceptor.OnAfterLog().
func (OnBeforeLogFunc) OnBeforeLog ¶ added in v0.9.0
OnBeforeLog implements Interceptor.OnBeforeLog().