refactor: Change logging level from info to debug for download and JS messages
Some checks failed
Tests & Quality Checks / Test on Python 3.11 (push) Has been cancelled
Tests & Quality Checks / Test on Python 3.12 (push) Has been cancelled
Tests & Quality Checks / Test on Python 3.11-1 (push) Has been cancelled
Tests & Quality Checks / Test on Python 3.12-1 (push) Has been cancelled
Tests & Quality Checks / Test on Python 3.10 (push) Has been cancelled
Tests & Quality Checks / Test on Python 3.11-2 (push) Has been cancelled
Tests & Quality Checks / Test on Python 3.12-2 (push) Has been cancelled
Tests & Quality Checks / Build Artifacts (push) Has been cancelled
Tests & Quality Checks / Build Artifacts-1 (push) Has been cancelled

This commit is contained in:
claudi 2026-02-18 13:19:38 +01:00
parent 6d8af7f8fb
commit dffc925bb6
2 changed files with 30 additions and 34 deletions

View file

@ -238,7 +238,7 @@ class _DragBridge(QObject):
Args: Args:
message: Debug message from JavaScript message: Debug message from JavaScript
""" """
logger.info(f"JS Debug: {message}") logger.debug(f"JS Debug: {message}")
class MainWindow(QMainWindow): class MainWindow(QMainWindow):
@ -327,7 +327,7 @@ class MainWindow(QMainWindow):
# Set up download handler # Set up download handler
profile = self.web_view.page().profile() profile = self.web_view.page().profile()
logger.info(f"Connecting download handler to profile: {profile}") logger.debug(f"Connecting download handler to profile: {profile}")
# CRITICAL: Connect download handler BEFORE any page loads # CRITICAL: Connect download handler BEFORE any page loads
profile.downloadRequested.connect(self._on_download_requested) profile.downloadRequested.connect(self._on_download_requested)
@ -338,9 +338,9 @@ class MainWindow(QMainWindow):
) )
if downloads_path: if downloads_path:
profile.setDownloadPath(downloads_path) profile.setDownloadPath(downloads_path)
logger.info(f"Download path set to: {downloads_path}") logger.debug(f"Download path set to: {downloads_path}")
logger.info("Download handler connected successfully") logger.debug("Download handler connected successfully")
# Set up central widget with layout # Set up central widget with layout
central_widget = QWidget() central_widget = QWidget()
@ -820,17 +820,13 @@ class MainWindow(QMainWindow):
Args: Args:
download: Download request from the web engine download: Download request from the web engine
""" """
logger.info("=" * 60)
logger.info("🔥 DOWNLOAD REQUESTED - Handler called!")
logger.info("=" * 60)
try: try:
# Log all download details for debugging # Log download details for debugging
logger.info(f"Download URL: {download.url().toString()}") logger.debug(f"Download URL: {download.url().toString()}")
logger.info(f"Download filename: {download.downloadFileName()}") logger.debug(f"Download filename: {download.downloadFileName()}")
logger.info(f"Download mime type: {download.mimeType()}") logger.debug(f"Download mime type: {download.mimeType()}")
logger.info(f"Download suggested filename: {download.suggestedFileName()}") logger.debug(f"Download suggested filename: {download.suggestedFileName()}")
logger.info(f"Download state: {download.state()}") logger.debug(f"Download state: {download.state()}")
# Get the system's Downloads folder # Get the system's Downloads folder
downloads_path = QStandardPaths.writableLocation( downloads_path = QStandardPaths.writableLocation(
@ -850,14 +846,14 @@ class MainWindow(QMainWindow):
# Construct full download path # Construct full download path
download_file = Path(downloads_path) / filename download_file = Path(downloads_path) / filename
logger.info(f"📁 Download will be saved to: {download_file}") logger.debug(f"Download will be saved to: {download_file}")
# Set download path and accept # Set download path and accept
download.setDownloadDirectory(str(download_file.parent)) download.setDownloadDirectory(str(download_file.parent))
download.setDownloadFileName(download_file.name) download.setDownloadFileName(download_file.name)
download.accept() download.accept()
logger.info(f"✅ Download accepted and started: {download_file}") logger.info(f"Download started: {filename}")
# Update status bar (temporarily) # Update status bar (temporarily)
self.status_bar.showMessage( self.status_bar.showMessage(
@ -866,7 +862,7 @@ class MainWindow(QMainWindow):
# Connect to state changed for progress tracking # Connect to state changed for progress tracking
download.stateChanged.connect( download.stateChanged.connect(
lambda state: logger.info(f"Download state changed to: {state}") lambda state: logger.debug(f"Download state changed to: {state}")
) )
# Connect to finished signal for completion feedback # Connect to finished signal for completion feedback
@ -875,8 +871,8 @@ class MainWindow(QMainWindow):
) )
except Exception as e: except Exception as e:
logger.error(f"Error handling download: {e}", exc_info=True) logger.error(f"Error handling download: {e}", exc_info=True)
self.status_bar.showMessage(f"❌ Download-Fehler: {e}", 5000) self.status_bar.showMessage(f"Download error: {e}", 5000)
def _on_download_finished(self, download: QWebEngineDownloadRequest, file_path: Path) -> None: def _on_download_finished(self, download: QWebEngineDownloadRequest, file_path: Path) -> None:
"""Handle download completion. """Handle download completion.
@ -890,12 +886,12 @@ class MainWindow(QMainWindow):
return return
state = download.state() state = download.state()
logger.info(f"Download finished with state: {state}") logger.debug(f"Download finished with state: {state}")
if state == QWebEngineDownloadRequest.DownloadState.DownloadCompleted: if state == QWebEngineDownloadRequest.DownloadState.DownloadCompleted:
logger.info(f"Download completed successfully: {file_path}") logger.info(f"Download completed: {file_path.name}")
self.status_bar.showMessage( self.status_bar.showMessage(
f"✅ Download abgeschlossen: {file_path.name}", 5000 f"Download completed: {file_path.name}", 5000
) )
elif state == QWebEngineDownloadRequest.DownloadState.DownloadCancelled: elif state == QWebEngineDownloadRequest.DownloadState.DownloadCancelled:
logger.info(f"Download cancelled: {file_path.name}") logger.info(f"Download cancelled: {file_path.name}")
@ -959,7 +955,7 @@ class MainWindow(QMainWindow):
# Map JS log levels to Python log levels using enum # Map JS log levels to Python log levels using enum
if level == QWebEnginePage.JavaScriptConsoleMessageLevel.InfoMessageLevel: if level == QWebEnginePage.JavaScriptConsoleMessageLevel.InfoMessageLevel:
logger.info(f"JS Console: {message}") logger.debug(f"JS Console: {message}")
elif level == QWebEnginePage.JavaScriptConsoleMessageLevel.WarningMessageLevel: elif level == QWebEnginePage.JavaScriptConsoleMessageLevel.WarningMessageLevel:
logger.warning(f"JS Console: {message}") logger.warning(f"JS Console: {message}")
logger.debug(f" at {source_id}:{line_number}") logger.debug(f" at {source_id}:{line_number}")
@ -982,11 +978,11 @@ class MainWindow(QMainWindow):
# Check if bridge script is loaded # Check if bridge script is loaded
def check_script(result): def check_script(result):
if result: if result:
logger.info("WebDrop Bridge script is active") logger.debug("WebDrop Bridge script is active")
logger.info("QWebChannel bridge is ready") logger.debug("QWebChannel bridge is ready")
else: else:
logger.error("WebDrop Bridge script NOT loaded!") logger.error("WebDrop Bridge script NOT loaded!")
logger.error(" Drag-and-drop conversion will NOT work") logger.error("Drag-and-drop conversion will not work")
# Execute JS to check if our script is loaded # Execute JS to check if our script is loaded
self.web_view.page().runJavaScript( self.web_view.page().runJavaScript(

View file

@ -74,7 +74,7 @@ class CustomWebEnginePage(QWebEnginePage):
] ]
if any(url_str.lower().endswith(ext) for ext in download_extensions): if any(url_str.lower().endswith(ext) for ext in download_extensions):
logger.info(f"🔽 Detected potential download URL: {url_str}") logger.debug(f"Detected potential download URL: {url_str}")
# This will trigger downloadRequested if it's a download # This will trigger downloadRequested if it's a download
return super().acceptNavigationRequest(url, nav_type, is_main_frame) return super().acceptNavigationRequest(url, nav_type, is_main_frame)
@ -90,13 +90,13 @@ class CustomWebEnginePage(QWebEnginePage):
Returns: Returns:
New page instance for the window New page instance for the window
""" """
logger.info(f"🪟 New window requested, type: {window_type}") logger.debug(f"New window requested, type: {window_type}")
# Create a temporary page to handle the download # Create a temporary page to handle the download
# This page will never be displayed but allows downloads to work # This page will never be displayed but allows downloads to work
download_page = QWebEnginePage(self.profile(), self) download_page = QWebEnginePage(self.profile(), self)
logger.info("Created temporary page for download/popup") logger.debug("Created temporary page for download/popup")
# Return the temporary page - it will trigger downloadRequested if it's a download # Return the temporary page - it will trigger downloadRequested if it's a download
return download_page return download_page
@ -127,7 +127,7 @@ class RestrictedWebEngineView(QWebEngineView):
custom_page = CustomWebEnginePage(self.profile, self) custom_page = CustomWebEnginePage(self.profile, self)
self.setPage(custom_page) self.setPage(custom_page)
logger.info( logger.debug(
"RestrictedWebEngineView initialized with CustomWebEnginePage and persistent profile" "RestrictedWebEngineView initialized with CustomWebEnginePage and persistent profile"
) )
@ -170,9 +170,9 @@ class RestrictedWebEngineView(QWebEngineView):
# Set cache size to 100 MB # Set cache size to 100 MB
profile.setHttpCacheMaximumSize(100 * 1024 * 1024) profile.setHttpCacheMaximumSize(100 * 1024 * 1024)
logger.info(f"Created persistent profile at: {profile_path}") logger.debug(f"Created persistent profile at: {profile_path}")
logger.info("Cookies policy: ForcePersistentCookies") logger.debug("Cookies policy: ForcePersistentCookies")
logger.info("HTTP cache: DiskHttpCache (100 MB)") logger.debug("HTTP cache: DiskHttpCache (100 MB)")
return profile return profile