-
Notifications
You must be signed in to change notification settings - Fork 12
/
logger.go
33 lines (27 loc) · 625 Bytes
/
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
package main
import (
"log"
"os"
"strings"
)
var debug bool
func init() {
debug = os.Getenv("DEBUG") != ""
}
// infoLog example:
// infoLog("timezone %s", timezone)
func infoLog(msg string, vars ...interface{}) {
log.Printf(strings.Join([]string{"[INFO]", msg}, " "), vars...)
}
// debugLog example:
// debugLog("timezone %s", timezone)
func debugLog(msg string, vars ...interface{}) {
if debug {
log.Printf(strings.Join([]string{"[DEBUG]", msg}, " "), vars...)
}
}
// errorLog example:
// errorLog(errors.Errorf("Invalid timezone %s", timezone))
func errorLog(err error) {
log.Printf("[ERROR] %+v\n", err)
}