Skip to content

Commit

Permalink
Merge branch 'logging_conf_to_apiver' into v2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
mjurbanski-reef committed Mar 29, 2024
2 parents 7e407fd + d06cb16 commit 055cbd0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
13 changes: 0 additions & 13 deletions b2sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,6 @@
######################################################################
from __future__ import annotations

# Set default logging handler to avoid "No handler found" warnings.
import logging

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


class UrllibWarningFilter:
def filter(self, record):
return record.msg != "Connection pool is full, discarding connection: %s"


logging.getLogger('urllib3.connectionpool').addFilter(UrllibWarningFilter())

import b2sdk.version # noqa: E402
__version__ = b2sdk.version.VERSION
assert __version__ # PEP-0396
13 changes: 13 additions & 0 deletions b2sdk/_v3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@
######################################################################
from __future__ import annotations

# Set default logging handler to avoid "No handler found" warnings.
import logging as _logging

_logging.getLogger("b2sdk").addHandler(_logging.NullHandler())


class UrllibWarningFilter:
def filter(self, record):
return record.msg != "Connection pool is full, discarding connection: %s"


_logging.getLogger('urllib3.connectionpool').addFilter(UrllibWarningFilter())

# this file maps the external interface into internal interface
# it will come handy if we ever need to move something

Expand Down
2 changes: 2 additions & 0 deletions changelog.d/+logging.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Move logging setup and `UrllibWarningFilter` class from `b2sdk.__init__.py` to `b2sdk._v3` (and thus `b2sdk.v2` & `b2sdk.v1`).
This will allow us to remove/change it in new apiver releases without the need to change the major semver version.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ target-version = "py37"

[tool.ruff.per-file-ignores]
"__init__.py" = ["I", "F401"]
"b2sdk/_v3/__init__.py" = ["E402"]
"b2sdk/v*/**" = ["I", "F403", "F405"]
"b2sdk/_v*/**" = ["I", "F403", "F405"]
"test/**" = ["D", "F403", "F405"]
Expand Down

0 comments on commit 055cbd0

Please sign in to comment.