2022-09-03 11:06:22 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"io"
|
|
|
|
"os"
|
|
|
|
|
2022-12-28 09:33:41 +00:00
|
|
|
"tuxpa.in/a/zlog"
|
2022-09-03 11:06:22 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
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()
|
2022-09-03 11:06:22 +00:00
|
|
|
_, _ = io.Copy(writer, os.Stdin)
|
|
|
|
}
|