fgeller / kt

Kafka command line tool that likes JSON
MIT License
950 stars 100 forks source link

Quiet mode to avoid printing informational messages to stderr #130

Closed nzbart closed 2 years ago

nzbart commented 2 years ago

When scripting in a loop, the informational output to stderr can be quite noisy:

found 1 brokers
found 22 groups
found 1 topics
...

An example of the code that outputs this information is here, and it doesn't appear to allow for any kind of switch to turn it off:

https://github.com/fgeller/kt/blob/6ba2d6d5038c112497cce23405ad27eacd96e6a0/group.go#L66

Is it possible to add a -quiet flag that would stop outputting informational messages to stderr? This flag would not disable errors from being output to stderr.

fgeller commented 2 years ago

hi @nzbart ! thanks for the feedback. i've drafted a version for the group command that changes the default to require the -verbose flag to print that additional information on the 130-logging branch in case you want to check it out. i'll port it to the other commands before i pull it into master.

nzbart commented 2 years ago

@fgeller I'm working on Windows and using the Docker image, so I'll need to figure out how to build this in a container using https://github.com/Paxa/kt and get back to you.

fgeller commented 2 years ago

hi @nzbart i pushed the changes to master - so you should be able to rebuild the docker image in the normal way. closing this optimistically for now, please re-open if you encounter any issues - thanks!

nzbart commented 2 years ago

@fgeller I was hoping that a new container image would be built since this image is referenced in your readme, but the most recent image is from 2018.

docker run evpavel/kt ls -l /usr/bin/kt
-rwxr-xr-x    1 root     root       8425923 Nov 13  2018 /usr/bin/kt

It might be worth removing this from your readme if this image is no longer being updated.

https://github.com/fgeller/kt/blob/834c58545c5ccf446779e39e896ff57ff05294e4/README.md?plain=1#L223-L227

fgeller commented 2 years ago

@nzbart can you build the image yourself? i have no experience with windows to help, sorry. i created a version of paxa's files that will allow you to build a docker image against the current master version of kt: https://github.com/fgeller/docker-kt/tree/dep-master

nzbart commented 2 years ago

@fgeller Windows can build and run Linux containers, so I have done that. However, I'm still getting the output when I don't use -verbose:

D:\dev\docker-kt [master ≡]> git log -1
commit 9172e3b41d8d5fe291414e54ee64b688bc175e16 (HEAD -> master, origin/master, origin/HEAD)
Author: Felix Geller <fgeller@protonmail.com>
Date:   Tue Aug 16 00:33:36 2022 +0200

    updates images and go installation
D:\dev\docker-kt [master ≡]> docker build --pull -t test . --quiet
sha256:77ef95975d734824107c74f4b4e5083c2963b607c5f77a9dd561434d53a1779e
D:\dev\docker-kt [master ≡]> docker run test kt group -brokers <redacted> -topic <redacted> | Out-Null
found 1 brokers
found 11 groups
found 1 topics
found partitions=[0] for topic=<redacted>