forked from zorkian/marshal
-
Notifications
You must be signed in to change notification settings - Fork 14
/
log.go
39 lines (31 loc) · 785 Bytes
/
log.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
35
36
37
38
39
/*
* portal - marshal
*
* this package exists for the simple reason that go vet complains bitterly
* that the go-logging package we use named its error printer 'Error' without
* the trailing 'f', and yet it accepts a format string. blah.
*
*/
package marshal
import (
"sync"
"github.com/op/go-logging"
)
var log *logging.Logger
var logMu = &sync.Mutex{}
func init() {
logMu.Lock()
defer logMu.Unlock()
if log != nil {
return
}
log = logging.MustGetLogger("KafkaMarshal")
logging.SetLevel(logging.INFO, "KafkaMarshal")
}
// SetLogger can be called with a logging.Logger in order to overwrite our internal
// logger. Useful if you need to control the logging (such as in tests).
func SetLogger(l *logging.Logger) {
logMu.Lock()
defer logMu.Unlock()
log = l
}