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

✨ add onlyErrors option to HttpLoggingInterceptor #610

Merged
merged 3 commits into from
May 8, 2024

Conversation

techouse
Copy link
Collaborator

@techouse techouse commented May 7, 2024

Add ability to HttpLoggingInterceptor to only log HTTP errors.

Rationale

The HttpLoggingInterceptor amazing, however, due to its verbosity the level of output can sometimes seem overwhelming. Having the ability to only show verbose logs for HTTP errors is therefore in my mind a nice feature.

Usage

Passing onlyErrors: true to the constructor will limit the logger to only log responses with an HTTP status code of 400 and above.


This PR is a response/solution to @Guldem's #609 (comment)

@techouse techouse added the enhancement New feature or request label May 7, 2024
@techouse techouse changed the title ✨ add onlyErrors option HttpLoggingInterceptor ✨ add onlyErrors option to HttpLoggingInterceptor May 7, 2024
Copy link

codecov bot commented May 7, 2024

Codecov Report

Attention: Patch coverage is 95.45455% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 93.05%. Comparing base (f5a56b6) to head (53bcf2e).

Files Patch % Lines
...lib/src/interceptors/http_logging_interceptor.dart 95.45% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #610      +/-   ##
===========================================
+ Coverage    92.85%   93.05%   +0.19%     
===========================================
  Files           22       22              
  Lines          490      504      +14     
===========================================
+ Hits           455      469      +14     
  Misses          35       35              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@techouse techouse added this to the 8.0.0 milestone May 8, 2024
@techouse
Copy link
Collaborator Author

techouse commented May 8, 2024

@Guldem would you mind throwing an eye on this?

P.S. I've also replaced all the (immutable) String concatenation and variable re-assignments with (mutable) StringBuffers for (hopefully) better performance.

Copy link
Contributor

@Guldem Guldem left a comment

Choose a reason for hiding this comment

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

Nice addition! Found 1 small thing

chopper/lib/src/interceptors/http_logging_interceptor.dart Outdated Show resolved Hide resolved
@techouse techouse merged commit a7293f4 into develop May 8, 2024
6 checks passed
@techouse techouse deleted the feat/http-error-logging-interceptor branch May 8, 2024 17:27
@techouse techouse mentioned this pull request May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants