From 0a8fb72a08d2dcd62a502973069d222171dd95ea Mon Sep 17 00:00:00 2001 From: Jae Kwon Date: Wed, 8 Jul 2015 13:07:05 -0700 Subject: [PATCH] filelogger -> stdinwriter --- Makefile | 6 +++--- cmd/filelogger/README.md | 6 ------ cmd/stdinwriter/README.md | 6 ++++++ cmd/{filelogger => stdinwriter}/main.go | 10 +++++----- scripts/unsafe_upgrade_barak.sh | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) delete mode 100644 cmd/filelogger/README.md create mode 100644 cmd/stdinwriter/README.md rename cmd/{filelogger => stdinwriter}/main.go (75%) diff --git a/Makefile b/Makefile index 637ac93be..7d909c378 100644 --- a/Makefile +++ b/Makefile @@ -6,19 +6,19 @@ install: go install github.com/tendermint/tendermint/cmd/tendermint go install github.com/tendermint/tendermint/cmd/barak go install github.com/tendermint/tendermint/cmd/debora - go install github.com/tendermint/tendermint/cmd/filelogger + go install github.com/tendermint/tendermint/cmd/stdinwriter build: go build -o build/tendermint github.com/tendermint/tendermint/cmd/tendermint go build -o build/barak github.com/tendermint/tendermint/cmd/barak go build -o build/debora github.com/tendermint/tendermint/cmd/debora - go build -o build/filelogger github.com/tendermint/tendermint/cmd/filelogger + go build -o build/stdinwriter github.com/tendermint/tendermint/cmd/stdinwriter build_race: go build -race -o build/tendermint github.com/tendermint/tendermint/cmd/tendermint go build -race -o build/barak github.com/tendermint/tendermint/cmd/barak go build -race -o build/debora github.com/tendermint/tendermint/cmd/debora - go build -race -o build/filelogger github.com/tendermint/tendermint/cmd/filelogger + go build -race -o build/stdinwriter github.com/tendermint/tendermint/cmd/stdinwriter test: build go test github.com/tendermint/tendermint/... diff --git a/cmd/filelogger/README.md b/cmd/filelogger/README.md deleted file mode 100644 index 3e63b502f..000000000 --- a/cmd/filelogger/README.md +++ /dev/null @@ -1,6 +0,0 @@ -filelogger reads from stdin and writes to the specified file, in a way compatible for logrotate to move around. -(see tendermint/common/os#AutoFile) - -```bash -some_command arg1 arg2 2>&1 | filelogger -o path_to_log.log -``` diff --git a/cmd/stdinwriter/README.md b/cmd/stdinwriter/README.md new file mode 100644 index 000000000..e0f0d9869 --- /dev/null +++ b/cmd/stdinwriter/README.md @@ -0,0 +1,6 @@ +stdinwriter reads from stdin and writes to the specified file, in a way compatible for logrotate to move around. +(see tendermint/common/os#AutoFile) + +```bash +some_command arg1 arg2 2>&1 | stdinwriter -o path_to_log.log +``` diff --git a/cmd/filelogger/main.go b/cmd/stdinwriter/main.go similarity index 75% rename from cmd/filelogger/main.go rename to cmd/stdinwriter/main.go index cb8c534a8..f254ca715 100644 --- a/cmd/filelogger/main.go +++ b/cmd/stdinwriter/main.go @@ -14,7 +14,7 @@ const readBufferSize = 1024 // Parse command-line options func parseFlags() (outpath string, version bool) { - flag.StringVar(&outpath, "outpath", "filelogger.out", "Output file name") + flag.StringVar(&outpath, "outpath", "stdinwriter.out", "Output file name") flag.BoolVar(&version, "version", false, "Version") flag.Parse() return @@ -25,13 +25,13 @@ func main() { // Read options outpath, version := parseFlags() if version { - fmt.Println(Fmt("filelogger version %v", Version)) + fmt.Println(Fmt("stdinwriter version %v", Version)) return } outfile, err := OpenAutoFile(outpath) if err != nil { - fmt.Println(Fmt("filelogger couldn't create outfile %v", outfile)) + fmt.Println(Fmt("stdinwriter couldn't create outfile %v", outfile)) os.Exit(1) } @@ -40,7 +40,7 @@ func main() { // Trap signal TrapSignal(func() { outfile.Close() - fmt.Println("filelogger shutting down") + fmt.Println("stdinwriter shutting down") }) } @@ -55,7 +55,7 @@ func writeToOutfile(outfile *AutoFile) { if err == io.EOF { os.Exit(0) } else { - fmt.Println("filelogger errored") + fmt.Println("stdinwriter errored") os.Exit(1) } } diff --git a/scripts/unsafe_upgrade_barak.sh b/scripts/unsafe_upgrade_barak.sh index e5a27e841..10ff8a849 100755 --- a/scripts/unsafe_upgrade_barak.sh +++ b/scripts/unsafe_upgrade_barak.sh @@ -7,7 +7,7 @@ sleep 10 debora --group default.upgrade close "[::]:46660" debora --group default.upgrade run -- bash -c "cd \$GOPATH/src/github.com/tendermint/tendermint; git pull origin develop; make" debora --group default.upgrade run -- bash -c "cd \$GOPATH/src/github.com/tendermint/tendermint; mkdir -p ~/.barak/logs" -debora --group default.upgrade run --bg --label barak -- bash -c "cd \$GOPATH/src/github.com/tendermint/tendermint; barak --options-file=cmd/barak/seed0 | filelogger -outpath ~/.barak/logs/barak.log" +debora --group default.upgrade run --bg --label barak -- bash -c "cd \$GOPATH/src/github.com/tendermint/tendermint; barak --options-file=cmd/barak/seed0 | stdinwriter -outpath ~/.barak/logs/barak.log" echo "Testing new barak..." debora list sleep 10