-
Notifications
You must be signed in to change notification settings - Fork 3
/
zerolog.go
82 lines (62 loc) · 1.63 KB
/
zerolog.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package loggo
import (
"github.com/rs/zerolog"
"io"
)
func NewZerolog(level string, output io.Writer) Log {
lvl, err := zerolog.ParseLevel(level)
if err != nil {
lvl = zerolog.InfoLevel
}
log := zerolog.New(output).With().Caller().Timestamp().Logger()
log.Level(lvl)
return &ZeloLog{&log}
}
type ZeloLog struct {
l *zerolog.Logger
}
func interfaces(v ...interface{}) []interface{} {
return append([]interface{}{}, v...)
}
func (z *ZeloLog) Debug(v ...interface{}) {
z.l.Debug().Interface("", interfaces(v)).Send()
}
func (z *ZeloLog) Debugf(msg string, v ...interface{}) {
z.l.Debug().Msgf(msg, v...)
}
func (z *ZeloLog) Info(v ...interface{}) {
z.l.Info().Interface("", interfaces(v)).Send()
}
func (z *ZeloLog) Infof(msg string, v ...interface{}) {
z.l.Info().Msgf(msg, v...)
}
func (z *ZeloLog) Warn(v ...interface{}) {
z.l.Warn().Interface("", interfaces(v)).Send()
}
func (z ZeloLog) Warnf(msg string, v ...interface{}) {
z.l.Warn().Msgf(msg, v...)
}
func (z *ZeloLog) Error(v ...interface{}) {
z.l.Debug().Interface("", interfaces(v)).Send()
}
func (z *ZeloLog) Errorf(msg string, v ...interface{}) {
z.l.Error().Msgf(msg, v...)
}
func (z *ZeloLog) Panic(v ...interface{}) {
z.l.Panic().Interface("", interfaces(v)).Send()
}
func (z *ZeloLog) Panicf(msg string, v ...interface{}) {
z.l.Panic().Msgf(msg, v...)
}
func (z *ZeloLog) Fatal(v ...interface{}) {
z.l.Fatal().Interface("", interfaces(v)).Send()
}
func (z *ZeloLog) Fatalf(msg string, v ...interface{}) {
z.l.Fatal().Msgf(msg, v...)
}
func (z *ZeloLog) Print(v ...interface{}) {
z.l.Print(v...)
}
func (z *ZeloLog) Println(v ...interface{}) {
z.l.Print(v...)
}