Logging does not inherit the root logger's configuration

Open Beginner friendly
#3,561 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
observability

Research direction

Start in github/init.py at lines 75-78 and inspect how the github logger is configured. Compare that behavior with the root logger and the workaround using logging.getLogger('github'); done means root configuration can propagate without messages being directly printed to stderr.

Written by the indexing model from the issue text.

Description

The following lines do not allow the github logger to let the root logger propagate all of its configuration to it.
They also cause messages to be directly printed to stderr, when one might not necessarily want that behaviour (e.g. letting rich format log messages before printing to stderr).
https://github.com/PyGithub/PyGithub/blob/5cdf6ab395c52efb652d0bc1f28fdf2e452b1b41/github/__init__.py#L75-L78

This can be worked around by doing the following:

import logging

import github


logging.getLogger('github').handlers.clear()
logging.getLogger('github').setLevel(logging.NOTSET)
Dominant language
Python
Stars
7.8k
Forks
1.9k
Avg merge
17m
Merged PRs (30d)
2

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.

More from PyGithub/PyGithub

All issues in PyGithub/PyGithub

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.