json-log-viewer
json-log-viewer copied to clipboard
Read from pipe
Hi,
Would be nice to be able to pipe the input. Example of how I would like to use it :
docker logs 0e9fcbe6e5b2 -f | Select-String -Pattern "^{" | jv
Please notice the -f
in docker's parameters.
So, no need to re-run the command to refresh results.
Do you think it's possible ?
Regards, LeNouveau
As a work around, what I do is to use a named-pipe on linux. Eg.
mkfifo jvfifo #need to do this once to create the fifo
then in one terminal
docker logs 0e9fcbe6e5b2 -f | Select-String -Pattern "^{" > jvfifo
and in another terminal window
jv jvfifo
Sadly I don't know of a way to do this on a Windows machine, Windows terminal support is worse than atrocious.
Piping is the feature that will make this nice log viewer actually usable for me.
As a work around, what I do is to use a named-pipe on linux. Eg.
mkfifo jvfifo #need to do this once to create the fifo
then in one terminal
docker logs 0e9fcbe6e5b2 -f | Select-String -Pattern "^{" > jvfifo
and in another terminal window
jv jvfifo
Sadly I don't know of a way to do this on a Windows machine, Windows terminal support is worse than atrocious.
Taking a look at the source code, unfortunately it looks like the log viewer loads the entire log file using readFileSync
and converts it to a string, instead of using a buffer or a stream. In that case, if using a named-pipe of stdin
for the input, the JSON log viewer would stall until stdin
ends, which iirc doesn't happen until Ctrl+D
.
We'd need to switch the readFileSync
with a buffer/stream implementation.