Skip to content

Commit

Permalink
Don't add NullHandlers
Browse files Browse the repository at this point in the history
This stops adding `NullHandler` instances to GitPython's loggers.
As noted in gitpython-developers#1806, when they were added in gitpython-developers#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
1 parent 78a82b3 commit bc42ee5
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 12 deletions.
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

0 comments on commit bc42ee5

Please sign in to comment.