-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog.go
69 lines (56 loc) · 1.46 KB
/
log.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
package log
import (
"io"
"os"
)
var (
output io.Writer = os.Stdout
level = LevelInfo
exit = os.Exit
formatter = NewTextFormatter()
constants = make(map[string]interface{})
)
// SetOutput sets logging output
func SetOutput(w io.Writer) {
output = w
}
// SetLevel sets logging minimum level
func SetLevel(lvl Level) {
level = lvl
}
// SetFormatter sets logging formatter
func SetFormatter(f Formatter) {
formatter = f
}
// SetConstant sets logging constants data
func SetConstant(key string, value interface{}) {
constants[key] = value
}
// Debug creates entry with message and logs in debug level
func Debug(message string) {
NewEntry().Debug(message)
}
// Info creates entry with message and logs in info level
func Info(message string) {
NewEntry().Info(message)
}
// Warning creates entry with message and logs in warning level
func Warning(message string) {
NewEntry().Warning(message)
}
// Error creates entry with message and logs in error level
func Error(message string) {
NewEntry().Error(message)
}
// Fatal creates entry with message and logs in fatal level so exit with code 1
func Fatal(message string) {
NewEntry().Fatal(message)
}
// With creates entry with data and returns that
func With(data interface{}) *Entry {
return NewEntry().With(data)
}
// Value creates entry with key, value and returns that
func Value(key string, value interface{}) *Entry {
return NewEntry().Value(key, value)
}