diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2021-12-26 16:01:23 -0500 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2021-12-26 16:27:05 -0500 |
commit | 2540fef72bc680a0ed92a94d73bf01cdd30044fa (patch) | |
tree | 42204f08b1d290e79972419f3235018a92586b74 /src/wheel/util.py | |
parent | 13cc63b105794ad7d014212036a0c1474546c9a4 (diff) | |
download | wheel-git-python-logging.tar.gz |
Replace bespoke logger with Python logging logger, restoring info/debug/warning levels to logged messages. Fixed missing f-string for 'wheelfile_path'.python-logging
Diffstat (limited to 'src/wheel/util.py')
-rw-r--r-- | src/wheel/util.py | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/src/wheel/util.py b/src/wheel/util.py index f4d8149..af470b5 100644 --- a/src/wheel/util.py +++ b/src/wheel/util.py @@ -1,7 +1,9 @@ from __future__ import annotations import base64 -import sys +import logging + +log = logging.getLogger('wheel') def urlsafe_b64encode(data: bytes) -> bytes: @@ -13,14 +15,3 @@ def urlsafe_b64decode(data: bytes) -> bytes: """urlsafe_b64decode without padding""" pad = b"=" * (4 - (len(data) & 3)) return base64.urlsafe_b64decode(data + pad) - - -def log(msg: str, *, error: bool = False) -> None: - stream = sys.stderr if error else sys.stdout - try: - print(msg, file=stream, flush=True) - except UnicodeEncodeError: - # emulate backslashreplace error handler - encoding = stream.encoding - msg = msg.encode(encoding, "backslashreplace").decode(encoding) - print(msg, file=stream, flush=True) |