-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.go
38 lines (31 loc) · 757 Bytes
/
main.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
package main
import (
log "github.com/Sirupsen/logrus"
"github.com/cloudposse/openvpn-api/src/cmd"
"github.com/spf13/viper"
"os"
)
func main() {
LoggerInit()
cmd.Execute()
}
// LoggerInit - Initialize logger configuration used for cli
func LoggerInit() {
viper.SetDefault("log_level", "info")
viper.BindEnv("log_level", "LOG_LEVEL")
// Log as JSON instead of the default ASCII formatter.
log.SetFormatter(&log.JSONFormatter{})
// Output to stderr instead of stdout, could also be a file.
log.SetOutput(os.Stderr)
// Only log the warning severity or above.
loglevel := viper.GetString("log_level")
switch loglevel {
case "debug":
log.SetLevel(log.DebugLevel)
break
case "info":
default:
log.SetLevel(log.InfoLevel)
break
}
}