mirror of
https://github.com/tendermint/tendermint.git
synced 2026-08-20 22:26:15 +00:00
filelogger -> stdinwriter
This commit is contained in:
@@ -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
|
||||
```
|
||||
@@ -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
|
||||
```
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user