zlog/cmd/prettylog/prettylog.go

27 lines
434 B
Go
Raw Permalink Normal View History

package main
import (
"fmt"
"io"
"os"
2022-12-28 09:33:41 +00:00
"tuxpa.in/a/zlog"
)
func isInputFromPipe() bool {
fileInfo, _ := os.Stdin.Stat()
return fileInfo.Mode()&os.ModeCharDevice == 0
}
func main() {
if !isInputFromPipe() {
fmt.Println("The command is intended to work with pipes.")
fmt.Println("Usage: app_with_zerolog | 2> >(prettylog)")
os.Exit(1)
return
}
2022-12-28 09:33:41 +00:00
writer := zlog.NewConsoleWriter()
_, _ = io.Copy(writer, os.Stdin)
}