forked from AliyunContainerService/log-pilot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. 增加本地filebeat的压缩包 2. 清理给alpine使用的glibc 3. 改用kingpin重写命令行参数解析
- Loading branch information
Showing
9 changed files
with
51 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,3 +24,4 @@ _testmain.go | |
*.prof | ||
bin/ | ||
docker-images/pilot | ||
log-pilot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
version = filebeat-5.6.9-linux-x86_66 |
Binary file not shown.
Binary file not shown.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package main | ||
|
||
import ( | ||
log "github.com/Sirupsen/logrus" | ||
"github.com/diablowu/log-pilot/pilot" | ||
"io/ioutil" | ||
"os" | ||
"github.com/alecthomas/kingpin" | ||
) | ||
|
||
const DEFUALT_VERSION = "0.1" | ||
|
||
func main() { | ||
|
||
app := kingpin.New("log-pilot", "collect loggger file from docker host") | ||
|
||
app.Version(DEFUALT_VERSION) | ||
|
||
// 模板路径 | ||
template := app.Flag("template", "Template filepath for fluentd or filebeat.").Short('t').Required().ExistingFile() | ||
|
||
// 主机文件系统挂在到容器内的路径,默认为 /host | ||
baseDir := app.Flag("base", "Directory which mount host root.").Default("/host").Short('b').ExistingDir() | ||
|
||
// 日志级别 | ||
level := app.Flag("log", "Log level").Default("info").Short('v').Enum("panic", "fatal", "error", "warn", "info", "debug") | ||
|
||
dry := app.Flag("dryrun", "Dry run.").Short('d').Default("false").Bool() | ||
|
||
|
||
kingpin.MustParse(app.Parse(os.Args[1:])) | ||
|
||
log.SetOutput(os.Stdout) | ||
|
||
// 不会error | ||
logLevel, _ := log.ParseLevel(*level) | ||
log.SetLevel(logLevel) | ||
|
||
if !*dry { | ||
b, err := ioutil.ReadFile(*template) | ||
if err != nil { | ||
log.Panic(err) | ||
} | ||
|
||
log.Fatal(pilot.Run(string(b), *baseDir)) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters