-
Notifications
You must be signed in to change notification settings - Fork 4
/
logging.go
41 lines (34 loc) · 858 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
package logging
import (
"fmt"
"strings"
"github.com/ConSol/go-neb-wrapper/neb"
"github.com/griesbacher/Iapetos/config"
)
const (
core = "core"
stdout = "stdout"
)
var destination string
//InitLogDestination checks the config values and inits the logging
func InitLogDestination() error {
dest := strings.ToLower(config.GetConfig().Logging.Destination)
if dest != core && dest != stdout {
return fmt.Errorf("This log destination is not supported. Supported are: %s %s", core, stdout)
}
neb.CoreFLog("Logging from now on to: %s", dest)
destination = dest
return nil
}
//Flog can be used to log ether to the core or stdout
func Flog(format string, a ...interface{}) {
if destination == core {
neb.CoreFLog(format, a)
} else if destination == stdout {
if a == nil {
fmt.Print(format)
} else {
fmt.Printf(format, a)
}
}
}