pytest-dev / pytest-dev/pytest

Allow control over log channels captured/displayed by CLI

Open
#9,239 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

plugin: logging type: proposal
Dominant language
Python
Stars
14.5k
Forks
3.4k
Avg merge
2d 9h
Merged PRs (30d)
35

Description

What's the problem this feature will solve?

My application emits a lot of logs. I'd like to view only a certain channel or channels when I specify e.g. --log-level=debug in the pytest CLI.

Describe the solution you'd like

It would be nice to be able to specify --log-channel=myapp.a.b one or more times to display only certain channels. The default could be --log-channel=* to display everything, but, if a non-default value is given, only the specified channels should be emitted to the console.

This would allow me to filter out log noise from irrelevant channels, especially at the debug level of my application, when trying to debug a specific failing test.

Alternative Solutions

I've not thought of any other solutions. I could add a log handler to my code directly, but that would defeat the purpose of configuring this on-demand via the CLI.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing pytest's CLI handling for --log-level and the logging capture/display path. Review the existing logging-related tests and determine how repeated --log-channel values should interact with the default behavior. Done means selected channels are displayed through the CLI while unrelated channels are filtered, with coverage for default and explicit channel selections.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.