Suppress errors from the console (#135)

* suppress console messages

* send errors to log

* stderr and stdout
This commit is contained in:
pdxlocations
2025-02-26 15:36:01 -08:00
committed by GitHub
parent c43d014417
commit 50c07827f1
+14 -7
View File
@@ -9,9 +9,11 @@ V 1.2.1
import curses
from pubsub import pub
import os
import sys
import logging
import traceback
import threading
import contextlib
from utilities.arg_parser import setup_parser
from utilities.interfaces import initialize_interface
@@ -24,8 +26,6 @@ from db_handler import init_nodedb, load_messages_from_db
import default_config as config
import globals
import os
# Set ncurses compatibility settings
os.environ["NCURSES_NO_UTF8_ACS"] = "1"
os.environ["LANG"] = "C.UTF-8"
@@ -74,8 +74,15 @@ def main(stdscr):
raise
if __name__ == "__main__":
try:
curses.wrapper(main)
except Exception as e:
logging.error("Fatal error in curses wrapper: %s", e)
logging.error("Traceback: %s", traceback.format_exc())
log_file = config.log_file_path
log_f = open(log_file, "a", buffering=1) # Enable line-buffering for immediate log writes
sys.stdout = log_f
sys.stderr = log_f
with contextlib.redirect_stderr(log_f), contextlib.redirect_stdout(log_f):
try:
curses.wrapper(main)
except Exception as e:
logging.error("Fatal error in curses wrapper: %s", e)
logging.error("Traceback: %s", traceback.format_exc())