-
Notifications
You must be signed in to change notification settings - Fork 1
/
taggedLogger.go
58 lines (47 loc) · 1.35 KB
/
taggedLogger.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package rogu
import (
"github.com/zekrotja/rogu/level"
)
type taggedLogger struct {
*logger
tag string
}
var _ Logger = (*taggedLogger)(nil)
// Trace creates a new log Event with level trace.
func (t *taggedLogger) Trace() *Event {
return t.newEvent(level.Trace).Tag(t.tag)
}
// Trace creates a new log Event with level debug.
func (t *taggedLogger) Debug() *Event {
return t.newEvent(level.Debug).Tag(t.tag)
}
// Trace creates a new log Event with info.
func (t *taggedLogger) Info() *Event {
return t.newEvent(level.Info).Tag(t.tag)
}
// Trace creates a new log Event with level warn.
func (t *taggedLogger) Warn() *Event {
return t.newEvent(level.Warn).Tag(t.tag)
}
// Trace creates a new log Event with level error.
func (t *taggedLogger) Error() *Event {
return t.newEvent(level.Error).Tag(t.tag)
}
// Trace creates a new log Event with level fatal.
//
// When commited, the programm will exit with exit
// code 1.
func (t *taggedLogger) Fatal() *Event {
return t.newEvent(level.Fatal).Tag(t.tag)
}
// Trace creates a new log Event with level panic.
//
// When commited, the program will panic at the
// called point.
func (t *taggedLogger) Panic() *Event {
return t.newEvent(level.Panic).Tag(t.tag)
}
// WithLevel returns a new log Event with the given level.
func (t *taggedLogger) WithLevel(lvl level.Level) *Event {
return t.newEvent(lvl).Tag(t.tag)
}