Pawan/plat 5615 level parameter#416
Open
SB-jigneshR wants to merge 4 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds first-class support for setting a logging level at BugsnagHandler construction time (and via Client.log_handler()), aligning the handler with standard Python logging patterns and avoiding the need to call setLevel() after instantiation.
Changes:
- Add optional
levelparameter toBugsnagHandler.__init__()and pass it tologging.Handler’s constructor. - Add optional
levelparameter toClient.log_handler()and thread it through toBugsnagHandler. - Add unit tests covering constructor-level filtering, client factory usage, and backward compatibility; document the change in the changelog.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
bugsnag/handlers.py |
Adds level parameter to BugsnagHandler and forwards it to the base logging.Handler initializer. |
bugsnag/client.py |
Extends Client.log_handler() to accept and pass through a handler level. |
tests/test_handlers.py |
Adds tests validating the new level parameter behavior and backward compatibility. |
CHANGELOG.md |
Documents the enhancement under the Unreleased section. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Goal
Add support for setting the logging level when creating a BugsnagHandler, allowing users to control the minimum log level at initialization time rather than only via setLevel() after creation.
Design
Added optional level parameter to BugsnagHandler.init() with default value logging.NOTSET (maintains backward compatibility)
Added optional level parameter to Client.log_handler() method
Parameter is passed to parent logging.Handler constructor via super().init(level=level)
Follows standard Python logging handler pattern
Changeset
handlers.py: Added level parameter to BugsnagHandler.init()
client.py: Added level parameter to Client.log_handler()
test_handlers.py: Added 5 new tests covering level parameter functionality and backward compatibility
CHANGELOG.md: Documented the enhancement
Testing
Unit tests verify level can be set via constructor and Client.log_handler()
Tests confirm handler respects the level (filters logs below threshold)
Backward compatibility tests ensure existing code works unchanged
All existing tests pass
Flake8 linting passes