-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
55 lines (45 loc) · 1.06 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package main
import (
"flag"
"os"
log "github.com/sirupsen/logrus"
"git.cryptic.systems/volker.raschek/dyndns-client/pkg/config"
"git.cryptic.systems/volker.raschek/dyndns-client/pkg/daemon"
)
var (
version string
configPath string
)
func main() {
switch os.Getenv("DYNDNS_CLIENT_LOGGER_LEVEL") {
case "DEBUG", "debug":
log.SetLevel(log.DebugLevel)
case "WARN", "warn":
log.SetLevel(log.WarnLevel)
case "ERROR", "error":
log.SetLevel(log.ErrorLevel)
case "FATAL", "fatal":
log.SetLevel(log.FatalLevel)
case "INFO", "info":
fallthrough
default:
log.SetLevel(log.InfoLevel)
}
switch os.Getenv("DYNDNS_CLIENT_LOGGER_FORMATTER") {
case "JSON", "json":
log.SetFormatter(&log.JSONFormatter{})
case "TEXT", "text":
fallthrough
default:
log.SetFormatter(&log.TextFormatter{
FullTimestamp: true,
})
}
flag.StringVar(&configPath, "config", "/etc/dyndns-client/config.json", "Path to json config")
log.Infof("version %v", version)
cnf, err := config.Read(configPath)
if err != nil {
log.Fatal(err.Error())
}
daemon.Start(cnf)
}