hytos / DTI_PID / DTI_PID / ExceptionHandler.py @ 596f227d
이력 | 보기 | 이력해설 | 다운로드 (1.01 KB)
1 |
# coding: utf-8
|
---|---|
2 |
""" This is exception handler module """
|
3 |
|
4 |
import sys |
5 |
import os |
6 |
|
7 |
from PyQt5.QtCore import * |
8 |
from PyQt5.QtGui import * |
9 |
from PyQt5.QtWidgets import * |
10 |
from PyQt5.QtXml import * |
11 |
from PyQt5.QtSvg import * |
12 |
from PyQt5 import QtWidgets |
13 |
import logging |
14 |
from App import App |
15 |
|
16 |
class QExceptionHandler(QObject): |
17 |
""" This is exception handler class """
|
18 |
|
19 |
errorSignal = pyqtSignal() |
20 |
|
21 |
def __init__(self): |
22 |
super(QExceptionHandler, self).__init__() |
23 |
|
24 |
self.log_path = os.path.join(os.getenv('ALLUSERSPROFILE'), App.NAME, App.NAME + '.log') |
25 |
self.logger = logging.getLogger(__name__)
|
26 |
logging.basicConfig(filename=self.log_path , filemode='w', level=logging.CRITICAL) |
27 |
|
28 |
def handler(self, exctype, value, traceback): |
29 |
""" log exception, file namd and line number """
|
30 |
|
31 |
message = 'error occured({}) in {}:{}'.format(value, traceback.tb_frame.f_code.co_filename, traceback.tb_lineno)
|
32 |
self.errorSignal.emit()
|
33 |
self.logger.critical('Unhandled exception: {}'.format(message)) |