Skip to content

feat(loguru): Sentry logs for Loguru #4445

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

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open

Conversation

sentrivana
Copy link
Contributor

@sentrivana sentrivana commented Jun 5, 2025

Allow to send Loguru logs to Sentry.

We can't parametrize them nicely, but this is a good first step.

Also:

  • Move some tests around. Tests specific to the stdlib logging integration were moved from the generic sentry logs tests to the logging integration tests.
  • Remove @minimum_python_37 from some tests that don't need 3.7+.
  • Dedupe some code by moving it to a superclass (_LoguruBaseHandler)

Closes #4151

Copy link

codecov bot commented Jun 5, 2025

Codecov Report

Attention: Patch coverage is 64.00000% with 18 lines in your changes missing coverage. Please review.

Project coverage is 80.55%. Comparing base (7f8571c) to head (8397b10).

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
sentry_sdk/integrations/loguru.py 64.00% 6 Missing and 12 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4445      +/-   ##
==========================================
- Coverage   80.68%   80.55%   -0.13%     
==========================================
  Files         142      142              
  Lines       15986    16025      +39     
  Branches     2732     2745      +13     
==========================================
+ Hits        12898    12909      +11     
- Misses       2230     2245      +15     
- Partials      858      871      +13     
Files with missing lines Coverage Δ
sentry_sdk/integrations/logging.py 82.69% <ø> (ø)
sentry_sdk/integrations/loguru.py 77.08% <64.00%> (-10.64%) ⬇️

... and 6 files with indirect coverage changes

@@ -283,3 +286,197 @@ def test_logging_dictionary_args(sentry_init, capture_events):
== "the value of foo is bar, and the value of bar is baz"
)
assert event["logentry"]["params"] == {"foo": "bar", "bar": "baz"}


def test_sentry_logs_warning(sentry_init, capture_envelopes):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These were just moved to this file from tests/test_logs.py

@sentrivana sentrivana marked this pull request as ready for review June 6, 2025 08:50
@sentrivana sentrivana requested a review from a team as a code owner June 6, 2025 08:50
@sentrivana
Copy link
Contributor Author

Additional change: removed setting sentry.message.template since we can't take apart Loguru logs at the moment.

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.

Make the loguru integration send Sentry logs
1 participant