Skip to content

Pawan/plat 5615 level parameter#416

Open
SB-jigneshR wants to merge 4 commits into
nextfrom
pawan/PLAT-5615-Level_Parameter
Open

Pawan/plat 5615 level parameter#416
SB-jigneshR wants to merge 4 commits into
nextfrom
pawan/PLAT-5615-Level_Parameter

Conversation

@SB-jigneshR
Copy link
Copy Markdown

@SB-jigneshR SB-jigneshR commented May 20, 2026

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

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 level parameter to BugsnagHandler.__init__() and pass it to logging.Handler’s constructor.
  • Add optional level parameter to Client.log_handler() and thread it through to BugsnagHandler.
  • 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.

Comment thread bugsnag/client.py Outdated
@SB-adityap SB-adityap marked this pull request as ready for review May 22, 2026 12:27
Copy link
Copy Markdown

@SB-adityap SB-adityap left a comment

Choose a reason for hiding this comment

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

Done

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