Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@lucavenir
Copy link
Contributor

@lucavenir lucavenir commented May 31, 2025

solves #357

Summary by Sourcery

Introduce a configurable printRequestExtra flag to TalkerDioLoggerSettings and update the interceptor and log generator to include request.extra data in logs when enabled.

New Features:

  • Allow logging of Dio request.extra parameters via a new printRequestExtra setting in TalkerDioLogger

Tests:

  • Add a unit test to verify extra parameters are formatted and logged in onRequest when enabled

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented May 31, 2025

Reviewer's Guide

Adds a new configurable option to log request.extra in the Dio logger: introduces and propagates a printRequestExtra setting, updates log formatter to include JSON-formatted extra data when enabled, and adds corresponding tests.

Sequence Diagram: Logging Request 'extra' Conditionally

sequenceDiagram
    participant DioClient
    participant TalkerDioLogger as "TalkerDioLogger (Interceptor)"
    participant RequestOptions
    participant Settings as "TalkerDioLoggerSettings"
    participant DioRequestLog as "DioRequestLog (Log Object)"
    participant Talker as "Talker (Logging Backend)"

    DioClient->>TalkerDioLogger: onRequest(options, handler)
    activate TalkerDioLogger
    TalkerDioLogger->>DioRequestLog: new DioRequestLog(options, settings)
    activate DioRequestLog
    DioRequestLog->>Settings: Reads settings.printRequestExtra
    alt if settings.printRequestExtra is true
        DioRequestLog->>RequestOptions: Reads options.extra
        Note right of DioRequestLog: Includes 'extra' in log message
    end
    DioRequestLog-->>TalkerDioLogger: log object (message generated)
    deactivate DioRequestLog
    TalkerDioLogger->>Talker: log(log object)
    TalkerDioLogger->>DioClient: handler.next(options)
    deactivate TalkerDioLogger
Loading

File-Level Changes

Change Details Files
Introduce printRequestExtra setting and propagate through logger
  • Added printRequestExtra flag in TalkerDioLoggerSettings with default false
  • Updated settings.copyWith to handle printRequestExtra
  • Extended TalkerDioLogger constructor to accept and forward printRequestExtra
lib/talker_dio_logger_settings.dart
lib/talker_dio_logger_interceptor.dart
Include request.extra in log output when enabled
  • Extracted requestOptions.extra into a Map copy
  • Conditionally convert extra to JSON and append under 'Extra:'
  • Guarded against empty extra when printRequestExtra is false
lib/dio_logs.dart
Add test for logging of request.extra
  • Created test case for onRequest logging of extras
  • Used a diverse extra map to verify JSON serialization
  • Asserted presence of 'Extra:' block in log message
test/logger_test.dart

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @lucavenir - I've reviewed your changes - here's some feedback:

  • Consider adding error handling in the catch block for extra encoding failures so you can log a fallback message instead of silently swallowing exceptions.
  • Add a test to verify that extras are not logged when printRequestExtra is false (default), ensuring the new flag behaves correctly.
Here's what I looked at during the review
  • 🟑 General issues: 1 issue found
  • 🟒 Security: all looks good
  • 🟒 Testing: all looks good
  • 🟒 Complexity: all looks good
  • 🟒 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click πŸ‘ or πŸ‘Ž on each comment and I'll use the feedback to improve your reviews.

@Frezyx Frezyx linked an issue Jun 2, 2025 that may be closed by this pull request
@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests βœ…

Project coverage is 98.61%. Comparing base (477f045) to head (5e6705e).
Report is 54 commits behind head on master.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #375      +/-   ##
==========================================
+ Coverage   98.17%   98.61%   +0.43%     
==========================================
  Files          28        3      -25     
  Lines         603      144     -459     
==========================================
- Hits          592      142     -450     
+ Misses         11        2       -9     

β˜” View full report in Codecov by Sentry.
πŸ“’ Have feedback on the report? Share it here.

πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Frezyx Frezyx merged commit 207fa6d into Frezyx:master Jun 2, 2025
1 check 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.

[talker_dio_logger] print request option's extra params

3 participants