forked from frain-dev/convoy-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
logger.go
47 lines (36 loc) · 1.08 KB
/
logger.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
package convoy_go
import (
"io"
log "github.com/frain-dev/convoy/pkg/log"
)
// Level represents a log level.
type Level int32
const (
// FatalLevel is used for undesired and unexpected events that
// the program cannot recover from.
FatalLevel Level = iota
// ErrorLevel is used for undesired and unexpected events that
// the program can recover from.
ErrorLevel
// WarnLevel is used for undesired but relatively expected events,
// which may indicate a problem.
WarnLevel
// InfoLevel is used for general informational log messages.
InfoLevel
// DebugLevel is the lowest level of logging.
// Debug logs are intended for debugging and development purposes.
DebugLevel
)
// iLogger is a stripped down logging interface that
// clients can implement.
type iLogger interface {
Debugf(format string, v ...interface{})
Errorf(format string, v ...interface{})
Infof(format string, v ...interface{})
Warnf(format string, v ...interface{})
}
func NewLogger(out io.Writer, lvl Level) *log.Logger {
logger := log.NewLogger(out)
logger.SetLevel(log.Level(lvl))
return logger
}