Added excepthook to logger module

This commit is contained in:
Manuel Cortez 2018-03-12 12:27:15 -06:00
parent d81db41f16
commit 1a9200cefe

View File

@ -3,12 +3,12 @@ from __future__ import unicode_literals # at top of module
import os import os
import logging import logging
import storage import storage
import traceback
storage.setup() storage.setup()
logging.basicConfig(filename=os.path.join(storage.data_directory, "info.log"), level=logging.DEBUG, filemode="w") logging.basicConfig(filename=os.path.join(storage.data_directory, "info.log"), level=logging.DEBUG, filemode="w")
sys.excepthook = lambda x, y, z: logging.critical(''.join(traceback.format_exception(x, y, z)))
log = logging.getLogger("main") log = logging.getLogger("main")
log.debug("Logger initialized. Saving debug to {0}".format(storage.data_directory,)) log.debug("Logger initialized. Saving debug to {0}".format(storage.data_directory,))
log.debug("Starting music-dl %s" % (application.version,))
log.debug("Application path is %s" % (paths.app_path(),))
import sys import sys
log.debug("Using Python version {0}".format(sys.version,)) log.debug("Using Python version {0}".format(sys.version,))
if sys.version[0] == "2": if sys.version[0] == "2":
@ -18,11 +18,13 @@ if sys.version[0] == "2":
fixes.setup() fixes.setup()
import i18n import i18n
i18n.setup() i18n.setup()
import widgetUtils
import application import application
import widgetUtils
from platform_utils import paths from platform_utils import paths
def setup(): def setup():
log.debug("Starting music-dl %s" % (application.version,))
log.debug("Application path is %s" % (paths.app_path(),))
from controller import mainController from controller import mainController
app = widgetUtils.mainLoopObject() app = widgetUtils.mainLoopObject()
log.debug("Created Application mainloop object") log.debug("Created Application mainloop object")