Send Javascript console messages to Python's logging.

master
Pacman Ghost 6 years ago
parent d6b343cb1f
commit 847597c80f
  1. 2
      vasl_templates/main.py
  2. 4
      vasl_templates/main_window.py

@ -34,7 +34,7 @@ def qtMessageHandler( msg_type, context, msg ):# pylint: disable=unused-argument
# via the MainWindow object - we filter them out here.
if "has no notify signal and is not constant" in msg:
return
logging.getLogger().log( _QT_LOGGING_LEVELS[msg_type], "%s", msg )
logging.getLogger( "qt" ).log( _QT_LOGGING_LEVELS[msg_type], "%s", msg )
# ---------------------------------------------------------------------

@ -2,6 +2,7 @@
import os
import re
import logging
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QLabel, QMessageBox
from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEngineProfile, QWebEnginePage
@ -25,7 +26,8 @@ class AppWebPage( QWebEnginePage ):
"""Log a Javascript console message."""
mo = _CONSOLE_SOURCE_REGEX.search( source_id )
source = mo.group(1) if mo else source_id
print( "{}:{} - {}".format( source, line_no, msg ) )
logger = logging.getLogger( "javascript" )
logger.info( "%s:%d - %s", source, line_no, msg )
# ---------------------------------------------------------------------

Loading…
Cancel
Save