Skip to content

Commit

Permalink
catch logger except for utf8
Browse files Browse the repository at this point in the history
  • Loading branch information
ali96343 committed Oct 28, 2023
1 parent ebc617f commit 62ad70c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions py4web/server_adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,12 @@ def logging_conf(level=logging.WARN, logger_name=__name__, test_log=False):
log_to["filemode"] = "w"
log_to["encoding"] = "utf-8"
else:
h = logging.FileHandler(log_file, mode="w", encoding="utf-8")
log_to.update({"handlers": [h]})
try:
h = logging.FileHandler(log_file, mode="w", encoding="utf-8")
log_to.update({"handlers": [h]})
except ( LookupError, KeyError, ValueError) as ex:
print(f"{ex}, bad encoding {__file__}")
pass

short_msg = "%(message)s > %(threadName)s > %(asctime)s.%(msecs)03d"
# long_msg = short_msg + " > %(funcName)s > %(filename)s:%(lineno)d > %(levelname)s"
Expand Down

0 comments on commit 62ad70c

Please sign in to comment.