Skip to content

Commit

Permalink
more robust logging setup
Browse files Browse the repository at this point in the history
  • Loading branch information
adal-chiriliuc-reef committed May 2, 2024
1 parent 923c83f commit 9fb1fca
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions b2/_internal/console_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -5380,7 +5380,7 @@ def _setup_logging(cls, args, argv):
elif args.verbose or args.debug_logs:
# set log level to DEBUG for ALL loggers (even those not belonging to B2), but without any handlers,
# those will added as needed (file and/or stderr)
logging.basicConfig(level=logging.DEBUG, handlers=[])
logging.basicConfig(level=logging.DEBUG, handlers=[], errors='backslashreplace')
else:
logger.setLevel(logging.CRITICAL + 1) # No logs!
if args.verbose:
Expand All @@ -5395,7 +5395,7 @@ def _setup_logging(cls, args, argv):
'%(asctime)s\t%(process)d\t%(thread)d\t%(name)s\t%(levelname)s\t%(message)s'
)
formatter.converter = time.gmtime
handler = logging.FileHandler('b2_cli.log')
handler = logging.FileHandler('b2_cli.log', errors='backslashreplace')
handler.setFormatter(formatter)

# logs from ALL loggers sent to the log file should be formatted this way
Expand Down
1 change: 1 addition & 0 deletions changelog.d/+logging-encoding.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Escape invalid unicode characters in log messages.

0 comments on commit 9fb1fca

Please sign in to comment.