Closed freak12techno closed 7 months ago
UPD: I decided to investigate this further and apparently it's not case I've described above, it's something with the decoding. Changing the binary to adding the following debug info:
if isInputFromPipe() {
written, err := io.Copy(writer, os.Stdin)
fmt.Printf("written %d\n", written)
fmt.Printf("err %s\n", err)
produces the following result:
2:25AM INF packet received dst_channel=channel-141 dst_port=transfer module=x/ibc/channel sequence=2384493 src_channel=channel-0 src_port=transfer
written 8192
err cannot decode event: json: cannot unmarshal string into Go value of type map[string]interface {}
After further investigation I am pretty sure journalctl outputs data partially, not line by line and ConsoleWriter#Write receives a bunch of bytes that are not valid JSON. Not sure if there's something that can be done easy with that though.
I have a service that uses zerolog and outputs logs in json. When I try to pipe its output to prettylog, it's only displaying its first line and then silently exits:
This makes it kinda useless for piping.
Adding a
for { }
orselect { }
after this line https://github.com/rs/zerolog/blob/master/cmd/prettylog/prettylog.go#L22 would likely fix that, as it seems like it creates a Writer and just exits. (I tested thefor {}
approach and it seems to work, but not sure if it's the optimal solution). This way it outputs data unless the process is killed by Ctrl+C: