From ad207ca4b181d034e03d71108539724688c1139f Mon Sep 17 00:00:00 2001 From: vrbober Date: Fri, 15 Nov 2024 02:44:53 +0100 Subject: [PATCH 1/2] Update main.py --- main.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/main.py b/main.py index 479c502c..223f907a 100644 --- a/main.py +++ b/main.py @@ -7,6 +7,16 @@ import src.setup as setup from src.ui.start_ui import StartUI +logging.basicConfig( + level=logging.INFO, + format="%(asctime)s %(levelname)s: %(message)s", + handlers=[logging.StreamHandler()] +) + +for handler in logging.getLogger().handlers: + if isinstance(handler, logging.StreamHandler): + handler.setStream(open(handler.stream.name, 'w', encoding='utf-8')) + def main(): try: config, language_info = setup.initialise( From 8c531b779573bb43d8caf32fbd38974da375839e Mon Sep 17 00:00:00 2001 From: vrbober Date: Sat, 16 Nov 2024 15:47:39 +0100 Subject: [PATCH 2/2] Update main.py --- main.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 223f907a..d79d41f3 100644 --- a/main.py +++ b/main.py @@ -1,3 +1,4 @@ +import sys from src.http.http_server import http_server import traceback from src.http.routes.routeable import routeable @@ -7,16 +8,18 @@ import src.setup as setup from src.ui.start_ui import StartUI +# Ensure sys.stdout and sys.stderr use UTF-8 encoding +if hasattr(sys.stdout, "reconfigure"): + sys.stdout.reconfigure(encoding='utf-8') + sys.stderr.reconfigure(encoding='utf-8') + +# Configure logging to use the updated streams logging.basicConfig( level=logging.INFO, format="%(asctime)s %(levelname)s: %(message)s", - handlers=[logging.StreamHandler()] + handlers=[logging.StreamHandler(sys.stdout)] ) -for handler in logging.getLogger().handlers: - if isinstance(handler, logging.StreamHandler): - handler.setStream(open(handler.stream.name, 'w', encoding='utf-8')) - def main(): try: config, language_info = setup.initialise(