logdna / logdna-cli

The LogDNA CLI allows you to signup for a new account and tail your server logs right from the command line.
https://logdna.com
MIT License
27 stars 21 forks source link

Write informational output to stderr for tail and search #43

Closed ghost closed 4 years ago

ghost commented 4 years ago

Plaintext summary lines, 'no result' lines, and internal errors are sent to stderr to not interfere with actual data for tail and search. This also fixes https://github.com/logdna/logdna-cli/issues/42 where piping output from tail and search under json flag would break due to summary line.

Before

logdna search "docker" -j | jq
parse error: Invalid numeric literal at line 1, column 7

After

logdna search "docker" -j | jq
search finished: 5000 line(s). hosts: all. apps: all. levels: all. tags: all. query: docker
{
  ...json output
}
jakedipity commented 4 years ago

utils.log seems to have some handling when console.log fails. I'm assuming that was added on purpose due to some issue, so I think we should try to respect that as well.

ghost commented 4 years ago

fixed

smusali commented 4 years ago

@ydshah2, can you mention this PR (#43) in #42 by saying this PR is intended to solve the issue? Thanks a lot in advance!

ghost commented 4 years ago

Adding discussions with @matt-march and @andkon, the change is not just to fix #42. That is what started the discussion. It is a move towards good design across the board. We are also keeping the stderr for internal output for both json and regular usecase for the sake of consistency. It is in line with what tools like curl do - something people are already familiar with. This will be a breaking change, and the version change will reflect that but the idea is to just do it the right way rather than add a flag just to satisfy the issue or for not being breaking.