forked from constabulary/gb
/
log.go
43 lines (35 loc) · 773 Bytes
/
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
package gb
import (
"fmt"
"os"
)
var (
// Quiet suppresses all logging output below ERROR
Quiet bool
// Verbose enables logging output below INFO
Verbose bool
)
func Fatalf(format string, args ...interface{}) {
fmt.Printf("FATAL "+format+"\n", args...)
os.Exit(1)
}
func Errorf(format string, args ...interface{}) {
fmt.Printf("ERROR "+format+"\n", args...)
}
func Warnf(format string, args ...interface{}) {
fmt.Printf("WARNING "+format+"\n", args...)
}
func Infof(format string, args ...interface{}) {
if !Quiet {
if Verbose {
fmt.Printf("INFO "+format+"\n", args...)
} else {
fmt.Printf(format+"\n", args...)
}
}
}
func Debugf(format string, args ...interface{}) {
if Verbose && !Quiet {
fmt.Printf("DEBUG "+format+"\n", args...)
}
}