-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathexample.go
More file actions
50 lines (39 loc) · 842 Bytes
/
example.go
File metadata and controls
50 lines (39 loc) · 842 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"fmt"
"github.com/koding/logging"
)
func main() {
// Default logger
logging.Debug("Debug")
logging.Info("Info")
logging.Notice("Notice")
logging.Warning("Warning")
logging.Error("Error")
logging.Critical("Critical")
// Custom logger with default handler
l := logging.NewLogger("test")
l.Debug("Debug")
l.Info("Info")
l.Notice("Notice")
l.Warning("Warning")
l.Error("Error")
l.Critical("Critical")
// Custom logger with custom handler
l2 := logging.NewLogger("test2")
l2.SetHandler(&MyHandler{})
l2.Debug("Debug")
l2.Info("Info")
l2.Notice("Notice")
l2.Warning("Warning")
l2.Error("Error")
l2.Critical("Critical")
}
type MyHandler struct {
logging.BaseHandler
}
func (h *MyHandler) Handle(rec *logging.Record) {
fmt.Printf(rec.Format, rec.Args...)
}
func (h *MyHandler) Close() {
}