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

feat(request): add flag to disable logging api warnings #925

Merged
merged 2 commits into from
Jan 17, 2025

Conversation

dcilke
Copy link
Member

@dcilke dcilke commented Nov 20, 2024

When using the client library and the vX api, it can be undesirable/noisy to log

This is a future API version, which may change without warning.

for every request.

@dcilke dcilke requested review from stipsan and bjoerge November 20, 2024 09:47
return getIt([
retry({shouldRetry}),
...envMiddleware,
printWarnings,
printWarnings(config?.ignoreSanityAPIWarnings),
Copy link
Contributor

@j33ty j33ty Nov 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another alternative here is to skip printWarnings middleware if config.ignoreSanityAPIWarnings flag is set. That makes printWarnings middleware simpler.

@judofyr
Copy link
Contributor

judofyr commented Nov 26, 2024

How about making the setting: ignoredAPIWarnings: string[] and yo need to do ignoredAPIWarnings: ["This is a future API version, which may change without warning."]? That way you end up not ignoring other potential API warnings that could appear in the future?

@dcilke
Copy link
Member Author

dcilke commented Nov 26, 2024

How about making the setting: ignoredAPIWarnings: string[] and yo need to do ignoredAPIWarnings: ["This is a future API version, which may change without warning."]? That way you end up not ignoring other potential API warnings that could appear in the future?

I guess that speaks to the intent of the flag. I'm thinking of this more as a log level filter. Since that isn't implemented, I opted for the existing pattern of an ignore... flag to mimic that behavior.

@bjoerge
Copy link
Member

bjoerge commented Nov 26, 2024

ignoredAPIWarnings: string[]

Agree with this - would be good to be able to opt out of particular warning(s), and still be able to get others. Guess that requires all warnings to be static strings (I suppose we don't have identifiers for these?), or allow providing a regex to match the warnings you want to ignore.

Might also be worth to consider skipping warnings that has already been logged?

@bjoerge bjoerge added this pull request to the merge queue Jan 17, 2025
Merged via the queue into main with commit 3f90ab0 Jan 17, 2025
15 checks passed
@bjoerge bjoerge deleted the dain/ignore-http-warnings branch January 17, 2025 13:35
@ecospark ecospark bot mentioned this pull request Jan 17, 2025
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.

4 participants