-
Notifications
You must be signed in to change notification settings - Fork 0
/
logger.go
34 lines (29 loc) · 990 Bytes
/
logger.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// The point of this package is to create a layer of abstraction
// on top of your favorite Go logging library, so that
// you can use your favorite logging library in Trinkets.
// A valid Logger implementation needs only 2 methods:
// * Info(string, ...interface{})
// * Error(string, ...interface{})
//
// To enable this you would use:
//
// logger.SetupLogBuilder(func(name string) logger.Logger {
// return your.Logger(name)
// })
//
package logger
// Logger types must support Info and Error functions
type Logger interface {
Info(string, ...interface{})
Error(string, ...interface{})
}
// Attrs are used for providing additional info in the log messages
type Attrs map[string]interface{}
// LogBuilderType function builds new log instances
type LogBuilderType func(name string) Logger
// NewLogger builder function
var NewLogger LogBuilderType
// SetupLogBuilder helper is used for setting up the log builder function
func SetupLogBuilder(b LogBuilderType) {
NewLogger = b
}