--log-level=error doesn't prevent excessive logging from Source Map Debug ID Injection Report
CLI Version
2.31.2
Operating System and Architecture
- [ ] macOS (arm64)
- [ ] macOS (x86_64)
- [ ] Linux (i686)
- [X] Linux (x86_64)
- [ ] Linux (armv7)
- [ ] Linux (aarch64)
- [ ] Windows (i686)
- [ ] Windows (x86_64)
Operating System Version
ubuntu 22
Link to reproduction repository
No response
CLI Command
sentry-cli --log-level=error sourcemaps inject --org [org] --project [project] ./dist && sentry-cli --log-level=error sourcemaps upload --org [org] --project [project] ./dist
Exact Reproduction Steps
- Run the following command:
sentry-cli --log-level=error sourcemaps inject --org [org] --project [project] ./dist && sentry-cli --log-level=error sourcemaps upload --org [org] --project [project] ./dist
- Observe the output, which contains a verbose "Source Map Debug ID Injection Report" with details for every file modified, eg:
> Searching ./dist
> Found 3030 files
> Analyzing 3030 sources
> Injecting debug ids
Source Map Debug ID Injection Report
Modified: The following source files have been modified to have debug ids
53ede84b-ab2c-55af-8520-9ad56e6bb05a - ./dist/api/redacted.js
abee9301-65c8-57bd-a348-66cb563d7f2c - ./dist/api/redacted/redacted.js
a13ba2f1-1675-51ad-a835-68409575a67c - ./dist/api/redacted/redacted.js
392e8470-9be5-51be-8fc6-49ddd1a03f28 - ./dist/api/redacted/redacted.js
f5afa70a-b86d-5477-b133-378c52765413 - ./dist/api/redacted/redacted.js
9ed8cbac-2745-5900-be9e-1b2a96af0d0d - ./dist/api/redacted/redacted.js
a4c90db2-9e9e-575e-a484-92f8170a1107 - ./dist/api/redacted/redacted.js
c25beab4-8bae-5cb3-92de-c2d41ad95695 - ./dist/api/redacted/redacted.js
aab48f07-65ea-5f1f-8071-2ce35a79579c - ./dist/api/redacted/redacted.js
5a7d7500-e842-5829-95f5-9960bcbac906 - ./dist/api/redacted/redacted.js
f2965af6-c057-5088-85b3-a029dbe0e58a - ./dist/api/redacted/redacted.js
Expected Results
I expect to receive only error logs since I set the flag --log-level=error.
Actual Results
I receive info on all 3k files uploaded.
Logs
> Searching ./dist
> Found 3030 files
> Analyzing 3030 sources
> Injecting debug ids
Source Map Debug ID Injection Report
Modified: The following source files have been modified to have debug ids
53ede84b-ab2c-55af-8520-9ad56e6bb05a - ./dist/api/redacted.js
abee9301-65c8-57bd-a348-66cb563d7f2c - ./dist/api/redacted/redacted.js
a13ba2f1-1675-51ad-a835-68409575a67c - ./dist/api/redacted/redacted.js
392e8470-9be5-51be-8fc6-49ddd1a03f28 - ./dist/api/redacted/redacted.js
f5afa70a-b86d-5477-b133-378c52765413 - ./dist/api/redacted/redacted.js
9ed8cbac-2745-5900-be9e-1b2a96af0d0d - ./dist/api/redacted/redacted.js
a4c90db2-9e9e-575e-a484-92f8170a1107 - ./dist/api/redacted/redacted.js
c25beab4-8bae-5cb3-92de-c2d41ad95695 - ./dist/api/redacted/redacted.js
aab48f07-65ea-5f1f-8071-2ce35a79579c - ./dist/api/redacted/redacted.js
5a7d7500-e842-5829-95f5-9960bcbac906 - ./dist/api/redacted/redacted.js
f2965af6-c057-5088-85b3-a029dbe0e58a - ./dist/api/redacted/redacted.js
...
Hi @mardesnic, thank you for the suggestion!
Looks like the reason setting the log level does not suppress the output from this command is that the output you are observing is generated by normal println! statements rather than being generated via the log library we use for logging statements, and so the output is unaffected by the log level.
While it would certainly be possible to fix this problem by converting these println! statements to logs at the info level, such a change would come with the drawback that we currently set our default log level at warning. Therefore, users who were previously used to seeing output from sourcemaps inject would stop seeing the output unless they manually set --log-level=info; due to the user confusion such a change might cause, it could probably be considered a breaking change which requires a new major release. We could address the concern of missing logs by reducing the default log level to info, but that might pollute other commands' output with log statements that were previously suppressed by default.
Suggested workaround
As a workaround, I would suggest redirecting stdout to /dev/null, like so:
sentry-cli sourcemaps inject ... > /dev/null
This will suppress the output from the println! statements, but you should still see any error messages logged to stderr.
Please let me know whether the workaround works for you, @mardesnic.
Also, if anyone else has any thoughts on how we should go about logging these messages in the sourcemaps inject command, please leave your thoughts on this issue! Given the potential drawbacks of changing the logging behavior of this command that I mentioned in my previous comment, we will likely only change the behavior if we see support for a change from multiple community members.
@szokeasaurusrex adding > /dev/null removed unwanted logs and solved my issue. Thank you for your quick suggestion!
Glad to hear it @mardesnic – I am going to leave this issue open in case anyone else wants to comment their thoughts here. If the issue remains inactive for a few weeks, I will let our stalebot automatically close it.
This issue has gone three weeks without activity. In another week, I will close it.
But! If you comment or otherwise update it, I will reset the clock, and if you remove the label Waiting for: Community, I will leave it alone ... forever!
"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀