-
Notifications
You must be signed in to change notification settings - Fork 3
/
funcs.go
56 lines (46 loc) · 1.29 KB
/
funcs.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
package logbuch
import (
"io"
"os"
)
var (
logger = NewLogger(os.Stdout, os.Stderr)
)
// SetOutput sets the output channels for the default logger.
// The first parameter is used for debug, info and warning levels.
// The second one for error level.
func SetOutput(stdout, stderr io.Writer) {
logger.SetOut(LevelDebug, stdout)
logger.SetOut(LevelInfo, stdout)
logger.SetOut(LevelWarning, stdout)
logger.SetOut(LevelError, stderr)
}
// SetLevel sets the logging level.
func SetLevel(level int) {
logger.SetLevel(level)
}
// SetFormatter sets the formatter of the default logger.
func SetFormatter(formatter Formatter) {
logger.SetFormatter(formatter)
}
// Debug logs a formatted debug message.
func Debug(msg string, params ...interface{}) {
logger.Debug(msg, params...)
}
// Info logs a formatted info message.
func Info(msg string, params ...interface{}) {
logger.Info(msg, params...)
}
// Warn logs a formatted warning message.
func Warn(msg string, params ...interface{}) {
logger.Warn(msg, params...)
}
// Error logs a formatted error message.
func Error(msg string, params ...interface{}) {
// maximum level cannot be disabled
logger.Error(msg, params...)
}
// Fatal logs a formatted error message and panics.
func Fatal(msg string, params ...interface{}) {
logger.Fatal(msg, params...)
}