mirror of
https://github.com/pdxlocations/contact.git
synced 2026-08-08 18:02:56 +02:00
Suppress errors from the console (#135)
* suppress console messages * send errors to log * stderr and stdout
This commit is contained in:
@@ -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())
|
||||
Reference in New Issue
Block a user