Skip to content

fix(logger): caplog working with parent Logger #6847

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 2 commits into
base: develop
Choose a base branch
from

Conversation

amin-farjadi
Copy link
Contributor

Issue number: 6753

Summary

Caplog fixture was not capturing logs made by parent loggers (logger with no child=True arg).

Changes

SupressFilter is not applied to pytest's LogCaptureHanlder.

User experience

Users can now use caplog fixture to test their parent logger's behaviour

def test_parent_logger_with_caplog(caplog, service_name):
    caplog.set_level("INFO")
    logger = Logger(service=service_name)
    logger.info("testing, testing...")

    assert len(caplog.records) == 1
    assert caplog.records[0].message == "testing, testing..."

Checklist

If your change doesn't seem to apply, please leave them unchecked.

Is this a breaking change? No

RFC issue number:

Checklist:

  • Migration process documented
  • Implement warnings (if it can live side by side)

Acknowledgment

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@amin-farjadi amin-farjadi requested a review from a team as a code owner June 21, 2025 00:25
@amin-farjadi amin-farjadi requested a review from anafalcao June 21, 2025 00:25
@pull-request-size pull-request-size bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jun 21, 2025
@amin-farjadi amin-farjadi force-pushed the fix/6753/caplog_with_parent_logger branch from d25d008 to 7a4087f Compare June 21, 2025 00:27
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
logger size/S Denotes a PR that changes 10-29 lines, ignoring generated files. tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant