Skip to content

Don't suppress messages when logging is not configured #1813

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

Merged
merged 4 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Don't add NullHandlers
This stops adding `NullHandler` instances to GitPython's loggers.
As noted in #1806, when they were added in #300 this prevented
errors when GitPython logged messages and logging was not enabled,
but since Python 3.2 there is a logger of last resort providing a
nicer default behavior of showing the messages. (They are still
shown with better formatting if logging is configured, even if
just done with logging.basicConfig(), so applications should still
typically configure logging.)
  • Loading branch information
EliahKagan committed Jan 26, 2024
commit bc42ee53275e38fc71b2f9d7ae58086a832e29c1
1 change: 0 additions & 1 deletion git/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
}

_logger = logging.getLogger(__name__)
_logger.addHandler(logging.NullHandler())

__all__ = ("Git",)

Expand Down
3 changes: 0 additions & 3 deletions git/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@

__all__ = ("GitConfigParser", "SectionConstraint")


_logger = logging.getLogger(__name__)
_logger.addHandler(logging.NullHandler())


CONFIG_LEVELS: ConfigLevels_Tup = ("system", "user", "global", "repository")
"""The configuration level of a configuration file."""
Expand Down
1 change: 0 additions & 1 deletion git/objects/commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
# ------------------------------------------------------------------------

_logger = logging.getLogger(__name__)
_logger.addHandler(logging.NullHandler())

__all__ = ("Commit",)

Expand Down
4 changes: 1 addition & 3 deletions git/objects/submodule/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@


# typing ----------------------------------------------------------------------

from typing import Callable, Dict, Mapping, Sequence, TYPE_CHECKING, cast
from typing import Any, Iterator, Union

Expand All @@ -50,14 +51,11 @@
from git.repo import Repo
from git.refs import Head


# -----------------------------------------------------------------------------

__all__ = ["Submodule", "UpdateProgress"]


_logger = logging.getLogger(__name__)
_logger.addHandler(logging.NullHandler())


class UpdateProgress(RemoteProgress):
Expand Down
1 change: 0 additions & 1 deletion git/objects/submodule/root.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
__all__ = ["RootModule", "RootUpdateProgress"]

_logger = logging.getLogger(__name__)
_logger.addHandler(logging.NullHandler())


class RootUpdateProgress(UpdateProgress):
Expand Down
3 changes: 0 additions & 3 deletions git/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,7 @@

# -------------------------------------------------------------


_logger = logging.getLogger(__name__)
_logger.addHandler(logging.NullHandler())


__all__ = ("RemoteProgress", "PushInfo", "FetchInfo", "Remote")

Expand Down