forked from CrowdStrike/gotel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
logging.go
53 lines (45 loc) · 971 Bytes
/
logging.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
package gotel
import (
"fmt"
"log"
"log/syslog"
)
type logging struct {
EnableSYSLOG bool
}
func (logger *logging) setLogOutput() {
loggerName := "GOTEL"
if logger.EnableSYSLOG {
log.Println("SYSLOG logging enabled")
syslogd, e := syslog.New(syslog.LOG_INFO, loggerName)
if e == nil {
log.SetOutput(syslogd)
}
} else {
log.Println("SYSLOG logging NOT enabled")
}
}
func (*logging) info(format string, a ...interface{}) {
if len(a) < 1 {
log.Printf("[INFO] %s\n", format)
} else {
msg := fmt.Sprintf(format, a...)
log.Printf("[INFO] %s\n", msg)
}
}
func (*logging) warn(format string, a ...interface{}) {
if len(a) < 1 {
log.Printf("[WARN] %s\n", format)
} else {
msg := fmt.Sprintf(format, a...)
log.Printf("[WARN] %s\n", msg)
}
}
func (*logging) err(format string, a ...interface{}) {
if len(a) < 1 {
log.Printf("[ERROR] %s\n", format)
} else {
msg := fmt.Sprintf(format, a...)
log.Printf("[ERROR] %s\n", msg)
}
}