Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't print debug logs by default in complete, env list #1056

Merged
merged 2 commits into from
Jun 10, 2024

Conversation

rrotter
Copy link
Contributor

@rrotter rrotter commented Jun 5, 2024

Suppress logs that I suspect we don't want to be printing by default:

Before:
default info logging prints unimportant information on basic commands

$ tk env list
{"level":"info","environments":5,"ms_to_find_jsonnet_files":20.682708,"ms_to_find_environments":1.767584,"time":"2024-06-05T16:01:40-04:00","message":"Found Tanka environments"}
NAME                                           NAMESPACE    SERVER
...

logs cannot be suppressed in completer because there is no way to send it --log-level flag

$ tk show <TAB>{"level":"debug","parallelism":12,"paths":1,"time":"2024-06-05T16:05:37-04:00","message":"Finding Tanka environments"}
{"level":"info","environments":5,"ms_to_find_jsonnet_files":20.73575,"ms_to_find_environments":2.033417,"time":"2024-06-05T16:05:37-04:00","message":"Found Tanka environments"}
 environments/

After:
the above examples work as they did on v0.26.0

$ tk env list
NAME                                           NAMESPACE    SERVER
$ tk show <TAB>environments/

setting a chattier log level still works as expected

$ tk env list --log-level=debug
{"level":"debug","parallelism":12,"paths":1,"time":"2024-06-07T10:08:29-04:00","message":"Finding Tanka environments"}
{"level":"debug","environments":5,"ms_to_find_jsonnet_files":21.046125,"ms_to_find_environments":2.08725,"time":"2024-06-07T10:08:29-04:00","message":"Found Tanka environments"}
NAME                                           NAMESPACE    SERVER
...

resolves #1048

@rrotter
Copy link
Contributor Author

rrotter commented Jun 5, 2024

If switching the default level to warn isn't desired an alternative would be changing the level of one or more info logs to debug and ensuring that some default (of info or higher) is set always globally to prevent complete from using trace as the default level. [edit: spelling]

@zerok
Copy link
Contributor

zerok commented Jun 7, 2024

Nice catch! Thank you 🙂 I think it would be better, though, to set the GlobalLevel explicitly to Info and go through the existing Info-lines to make sure that they are really supposed to be Info. Would this be OK for you in this context and do you perhaps have time to update your PR? Otherwise: Would it be ok for you if I update your PR accordingly?

@rrotter rrotter marked this pull request as draft June 7, 2024 13:20
rrotter added 2 commits June 7, 2024 09:52
This was printing by default on `tk env list` and in the shell completer.
Set default log level early so tk complete (and any other commands that
don't read `--log-level`) won't print debug/trace level logs.
@rrotter rrotter force-pushed the default_log_level branch from 6c8c66c to 4dc0755 Compare June 7, 2024 14:00
@rrotter rrotter changed the title set default log level to warn don't print debug logs by default in complete, env list Jun 7, 2024
@rrotter rrotter marked this pull request as ready for review June 7, 2024 14:02
@rrotter
Copy link
Contributor Author

rrotter commented Jun 7, 2024

Good point, I'm not actually sure if there are any other messages at Info that should be Debug other than the one I identified in this PR and associated bug report. Fixed that one, changed the PR and title accordingly.

@zerok
Copy link
Contributor

zerok commented Jun 10, 2024

Thank you! Looks great!

@zerok zerok merged commit 8733fad into grafana:main Jun 10, 2024
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tk show completion prints debug info to terminal
2 participants