diff --git a/git/util.py b/git/util.py index 5ccd2b04c..4a284b785 100644 --- a/git/util.py +++ b/git/util.py @@ -1295,5 +1295,20 @@ def list_items(cls, repo: "Repo", *args: Any, **kwargs: Any) -> Any: class NullHandler(logging.Handler): - def emit(self, record: object) -> None: + """Deprecated, use :class:`logging.NullHandler` instead. + + This noop handler is like :class:`~logging.NullHandler` in the standard library, + which should be used instead, because it is now always available, and it overrides + more logging methods to make them noop. This class only overrides :meth:`emit`. + """ + + def __init__(self, level: int = logging.NOTSET) -> None: + warnings.warn( + "NullHandler in git.util is deprecated. Use logging.NullHandler instead.", + DeprecationWarning, + stacklevel=2, + ) + super().__init__(level) + + def emit(self, record: logging.LogRecord) -> None: pass