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
This commit is contained in:
hiijoshi 2026-03-28 14:01:59 +05:30
parent 857db0532d
commit bc51d2e045
3 changed files with 5 additions and 5 deletions

View file

@ -41,7 +41,8 @@ dependencies = [
"backports-zstd; python_version < '3.14'", # for python < 3.14.
"xxhash>=2.0.0",
"jsonargparse>=4.47.0",
"PyYAML>=6.0.2", # we need to register our types with yaml, jsonargparse uses yaml for config files
"PyYAML>=6.0.2",
"structlog",
]
[project.optional-dependencies]

View file

@ -1,4 +1,3 @@
import logging
import io
import os
import platform # python stdlib import - if this fails, check that cwd != src/borg/
@ -58,7 +57,7 @@ def sysinfo():
return "\n".join(info)
def log_multi(*msgs, level=logging.INFO, logger=logger):
def log_multi(*msgs, level=20, logger=logger):
"""
Log multiple lines of text, emitting each line via a separate logging call for cosmetic reasons.

View file

@ -1,4 +1,4 @@
import logging
import structlog
import json
import os
import os.path
@ -62,7 +62,7 @@ def yes(
"""
def output(msg, msg_type, is_prompt=False, **kwargs):
json_output = getattr(logging.getLogger("borg"), "json", False)
json_output = getattr(structlog.get_logger("borg"), "json", False)
if json_output:
kwargs |= dict(type="question_%s" % msg_type, msgid=msgid, message=msg)
print(json.dumps(kwargs), file=sys.stderr)