mirror of
https://github.com/borgbackup/borg.git
synced 2026-04-07 01:56:14 -04:00
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:
parent
857db0532d
commit
bc51d2e045
3 changed files with 5 additions and 5 deletions
|
|
@ -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]
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue