Skip to content

Commit bc51d2e

Browse files
committed
refactor: replace logging with structlog in helpers (issue #9529)
- helpers/yes_no.py: replace logging.getLogger with structlog.get_logger - helpers/misc.py: remove unused logging import, use plain int for level
1 parent 857db05 commit bc51d2e

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ dependencies = [
4141
"backports-zstd; python_version < '3.14'", # for python < 3.14.
4242
"xxhash>=2.0.0",
4343
"jsonargparse>=4.47.0",
44-
"PyYAML>=6.0.2", # we need to register our types with yaml, jsonargparse uses yaml for config files
44+
"PyYAML>=6.0.2",
45+
"structlog",
4546
]
4647

4748
[project.optional-dependencies]

src/borg/helpers/misc.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import logging
21
import io
32
import os
43
import platform # python stdlib import - if this fails, check that cwd != src/borg/
@@ -58,7 +57,7 @@ def sysinfo():
5857
return "\n".join(info)
5958

6059

61-
def log_multi(*msgs, level=logging.INFO, logger=logger):
60+
def log_multi(*msgs, level=20, logger=logger):
6261
"""
6362
Log multiple lines of text, emitting each line via a separate logging call for cosmetic reasons.
6463

src/borg/helpers/yes_no.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import logging
1+
import structlog
22
import json
33
import os
44
import os.path
@@ -62,7 +62,7 @@ def yes(
6262
"""
6363

6464
def output(msg, msg_type, is_prompt=False, **kwargs):
65-
json_output = getattr(logging.getLogger("borg"), "json", False)
65+
json_output = getattr(structlog.get_logger("borg"), "json", False)
6666
if json_output:
6767
kwargs |= dict(type="question_%s" % msg_type, msgid=msgid, message=msg)
6868
print(json.dumps(kwargs), file=sys.stderr)

0 commit comments

Comments
 (0)