-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlog.go
More file actions
29 lines (20 loc) · 717 Bytes
/
Copy pathlog.go
File metadata and controls
29 lines (20 loc) · 717 Bytes
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
package qbin
import (
"os"
"github.com/op/go-logging"
)
// Log refers to the main logger instance used by the qbin application.
var Log = logging.MustGetLogger("example")
var leveled logging.LeveledBackend
// SetLogLevel changes how much information is printed to Stdout.
func SetLogLevel(level logging.Level) {
leveled.SetLevel(level, "")
}
func init() {
backend := logging.NewLogBackend(os.Stdout, "", 0)
format := logging.MustStringFormatter(`%{color}%{time:15:04:05.000} %{shortfunc}: %{level:.4s} %{color:reset} %{message}`)
formatter := logging.NewBackendFormatter(backend, format)
leveled = logging.AddModuleLevel(formatter)
leveled.SetLevel(logging.NOTICE, "")
logging.SetBackend(leveled)
}