Release v0.2.3
This commit is contained in:
+24
-1
@@ -4,7 +4,7 @@ import logging
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from PySide6.QtCore import QStandardPaths
|
||||
from PySide6.QtCore import QtMsgType, QStandardPaths, qInstallMessageHandler
|
||||
from PySide6.QtGui import QIcon
|
||||
from PySide6.QtWidgets import QApplication, QMessageBox
|
||||
|
||||
@@ -29,6 +29,28 @@ def configure_logging() -> Path:
|
||||
return log_path
|
||||
|
||||
|
||||
def install_qt_message_logger() -> None:
|
||||
level_map = {
|
||||
QtMsgType.QtDebugMsg: logging.DEBUG,
|
||||
QtMsgType.QtInfoMsg: logging.INFO,
|
||||
QtMsgType.QtWarningMsg: logging.WARNING,
|
||||
QtMsgType.QtCriticalMsg: logging.ERROR,
|
||||
QtMsgType.QtFatalMsg: logging.CRITICAL,
|
||||
}
|
||||
|
||||
def handler(message_type, context, message) -> None:
|
||||
level = level_map.get(message_type, logging.INFO)
|
||||
logging.getLogger("Qt").log(
|
||||
level,
|
||||
"%s (%s:%s)",
|
||||
message,
|
||||
context.file or "",
|
||||
context.line,
|
||||
)
|
||||
|
||||
qInstallMessageHandler(handler)
|
||||
|
||||
|
||||
def main() -> int:
|
||||
app = QApplication(sys.argv)
|
||||
app.setApplicationName("PDFReaderLite")
|
||||
@@ -36,6 +58,7 @@ def main() -> int:
|
||||
app.setApplicationVersion(__version__)
|
||||
app.setWindowIcon(QIcon(software_icon_path().as_posix()))
|
||||
log_path = configure_logging()
|
||||
install_qt_message_logger()
|
||||
|
||||
def handle_exception(exc_type, exc_value, exc_traceback) -> None:
|
||||
logging.exception("Unhandled exception", exc_info=(exc_type, exc_value, exc_traceback))
|
||||
|
||||
Reference in New Issue
Block a user