filelogger -> stdinwriter

This commit is contained in:
Jae Kwon
2015-07-08 13:07:05 -07:00
parent e0c7947544
commit 0a8fb72a08
5 changed files with 15 additions and 15 deletions

View File

@ -6,19 +6,19 @@ install:
go install github.com/tendermint/tendermint/cmd/tendermint go install github.com/tendermint/tendermint/cmd/tendermint
go install github.com/tendermint/tendermint/cmd/barak go install github.com/tendermint/tendermint/cmd/barak
go install github.com/tendermint/tendermint/cmd/debora 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: build:
go build -o build/tendermint github.com/tendermint/tendermint/cmd/tendermint 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/barak github.com/tendermint/tendermint/cmd/barak
go build -o build/debora github.com/tendermint/tendermint/cmd/debora 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: build_race:
go build -race -o build/tendermint github.com/tendermint/tendermint/cmd/tendermint 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/barak github.com/tendermint/tendermint/cmd/barak
go build -race -o build/debora github.com/tendermint/tendermint/cmd/debora 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 test: build
go test github.com/tendermint/tendermint/... go test github.com/tendermint/tendermint/...

View File

@ -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
```

View File

@ -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
```

View File

@ -14,7 +14,7 @@ const readBufferSize = 1024
// Parse command-line options // Parse command-line options
func parseFlags() (outpath string, version bool) { 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.BoolVar(&version, "version", false, "Version")
flag.Parse() flag.Parse()
return return
@ -25,13 +25,13 @@ func main() {
// Read options // Read options
outpath, version := parseFlags() outpath, version := parseFlags()
if version { if version {
fmt.Println(Fmt("filelogger version %v", Version)) fmt.Println(Fmt("stdinwriter version %v", Version))
return return
} }
outfile, err := OpenAutoFile(outpath) outfile, err := OpenAutoFile(outpath)
if err != nil { 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) os.Exit(1)
} }
@ -40,7 +40,7 @@ func main() {
// Trap signal // Trap signal
TrapSignal(func() { TrapSignal(func() {
outfile.Close() outfile.Close()
fmt.Println("filelogger shutting down") fmt.Println("stdinwriter shutting down")
}) })
} }
@ -55,7 +55,7 @@ func writeToOutfile(outfile *AutoFile) {
if err == io.EOF { if err == io.EOF {
os.Exit(0) os.Exit(0)
} else { } else {
fmt.Println("filelogger errored") fmt.Println("stdinwriter errored")
os.Exit(1) os.Exit(1)
} }
} }

View File

@ -7,7 +7,7 @@ sleep 10
debora --group default.upgrade close "[::]:46660" 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; 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 -- 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..." echo "Testing new barak..."
debora list debora list
sleep 10 sleep 10