Debian Codegraph @

handler.go

raw symbols SCIP
1 package logg
2
3 // Handler is used to handle log events, outputting them to
4 // stdio or sending them to remote services. See the "handlers"
5 // directory for implementations.
6 //
7 // It is left up to Handlers to implement thread-safety.
8 type Handler interface {
9 // HandleLog is invoked for each log event.
10 // Note that if the Entry is going to be used after the call to HandleLog
11 // in the handler chain returns, it must be cloned with Clone(). See
12 // the memory.Handler implementation for an example.
13 //
14 // The Entry can be modified if needed, e.g. when passed down via
15 // a multi.Handler (e.g. to sanitize the data).
16 HandleLog(e *Entry) error
17 }
18
19 // The HandlerFunc type is an adapter to allow the use of ordinary functions as
20 // log handlers. If f is a function with the appropriate signature,
21 // HandlerFunc(f) is a Handler object that calls f.
22 type HandlerFunc func(*Entry) error
23
24 // HandleLog calls f(e).
25 func (f HandlerFunc) HandleLog(e *Entry) error {
26 return f(e)
27 }