-
Notifications
You must be signed in to change notification settings - Fork 400
/
main.go
45 lines (36 loc) · 819 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
39
40
41
42
43
44
45
package main
import (
"flag"
"github.com/AliyunContainerService/log-pilot/pilot"
log "github.com/Sirupsen/logrus"
"io/ioutil"
"os"
"path/filepath"
)
func main() {
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()
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 {
panic(err)
}
log.SetLevel(logLevel)
b, err := ioutil.ReadFile(*template)
if err != nil {
panic(err)
}
log.Fatal(pilot.Run(string(b), baseDir))
}