-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
52 lines (43 loc) · 1.02 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
package main
import (
"flag"
log "github.com/sirupsen/logrus"
"os"
"path/filepath"
log2 "watchlog/log"
)
func main() {
// -template /pilot/filebeat.tpl -base /host -log-level debug
template := flag.String("template", "", "Template filepath for fluentd or filebeat.")
base := flag.String("base", "", "Directory which mount host root.")
level := flag.String("log-level", "INFO", "Log level")
flag.Parse()
if os.Getenv("DOCKER_API_VERSION") == "" {
err := os.Setenv("DOCKER_API_VERSION", "1.23")
if err != nil {
log.Errorf(err.Error())
return
}
}
if os.Getenv("RUNTIME_TYPE") == "" {
log.Errorf("Please set service type, (docker|containerd)")
}
baseDir, err := filepath.Abs(*base)
if err != nil {
panic(err)
}
if baseDir == "/" {
baseDir = ""
}
if *template == "" {
panic("template file can not be empty")
}
log.SetOutput(os.Stdout)
logLevel, err := log.ParseLevel(*level)
if err != nil {
log.Errorf(err.Error())
panic(err)
}
log.SetLevel(logLevel)
log.Fatal(log2.Run(*template, baseDir))
}