Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions doc/ThumbnailBackground/ThumnaiBg_simplified.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
102 changes: 102 additions & 0 deletions doc/ThumbnailBackground/TumbnailBg.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 10 additions & 1 deletion locales/de_DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,14 @@
"actions.media-action.show-thumbnail-switch.label": "Bild des spielenden Titels anzeigen",
"actions.media-action.show-thumbnail-switch.subtitle": "Den Titelbild des aktuell spielenden Titels anzeigen",
"actions.media-action-bind-to-player.all-players": "Alle Spieler",
"actions.info.seperator.text": "Trenntext:"
"actions.info.seperator.text": "Trenntext:",
"actions.thumbnail-background.size-mode.label": "Miniaturbild-Größe",
"actions.thumbnail-background.size-mode.subtitle": "Größe des Miniaturbilds auf dem Deck festlegen",
"actions.thumbnail-background.size-mode.stretch": "Strecken um zu passen",
"actions.thumbnail-background.size-mode.fill": "Bildschirm füllen",
"settings.title": "Plugin-Einstellungen",
"settings.composite-timeout.label": "Composite-Timeout",
"settings.composite-timeout.subtitle": "Verzögerung vor dem Zusammensetzen von Miniaturbildern (ms)",
"settings.log-level.label": "Log-Ebene",
"settings.log-level.subtitle": "Kontrollen Sie die Ausführlichkeit der Plugin-Protokollierung"
}
11 changes: 10 additions & 1 deletion locales/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,14 @@
"actions.media-action.show-thumbnail-switch.label": "Show thumbnail of the playing song",
"actions.media-action.show-thumbnail-switch.subtitle": "Show the thumbnail of the currently playing media",
"actions.media-action-bind-to-player.all-players": "All Players",
"actions.info.seperator.text": "Seperator Text:"
"actions.info.seperator.text": "Seperator Text:",
"actions.thumbnail-background.size-mode.label": "Thumbnail Size",
"actions.thumbnail-background.size-mode.subtitle": "Set the size of the thumbnail on the deck",
"actions.thumbnail-background.size-mode.stretch": "Stretch to Fit",
"actions.thumbnail-background.size-mode.fill": "Fill Screen",
"settings.title": "Plugin Settings",
"settings.composite-timeout.label": "Composite Timeout",
"settings.composite-timeout.subtitle": "Delay before compositing thumbnails (ms)",
"settings.log-level.label": "Log Level",
"settings.log-level.subtitle": "Control the verbosity of plugin logging"
}
89 changes: 89 additions & 0 deletions log_wrapper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
"""
Plugin-level logging wrapper for MediaPlugin.

Provides a configurable logger that can be controlled independently of the parent application's
log level, allowing fine-grained control over MediaPlugin's log output.
"""

from loguru import logger as _loguru_logger
import sys

# Log levels from highest to lowest severity
LOG_LEVELS = {
"CRITICAL": 50,
"ERROR": 40,
"WARNING": 30,
"INFO": 20,
"DEBUG": 10,
"TRACE": 5,
}

# Current log level for the plugin
_current_log_level = "INFO"


class PluginLogger:
"""Wrapper around loguru logger with plugin-level configuration."""

def __init__(self):
self._logger = _loguru_logger

def _should_log(self, level: str) -> bool:
"""Check if a message at the given level should be logged."""
level_value = LOG_LEVELS.get(level.upper(), 20)
current_value = LOG_LEVELS.get(_current_log_level.upper(), 20)
return level_value >= current_value

def trace(self, message: str, *args, **kwargs):
"""Log a trace level message."""
if self._should_log("TRACE"):
self._logger.trace(message, *args, **kwargs)

def debug(self, message: str, *args, **kwargs):
"""Log a debug level message."""
if self._should_log("DEBUG"):
self._logger.debug(message, *args, **kwargs)

def info(self, message: str, *args, **kwargs):
"""Log an info level message."""
if self._should_log("INFO"):
self._logger.info(message, *args, **kwargs)

def warning(self, message: str, *args, **kwargs):
"""Log a warning level message."""
if self._should_log("WARNING"):
self._logger.warning(message, *args, **kwargs)

def error(self, message: str, *args, **kwargs):
"""Log an error level message."""
if self._should_log("ERROR"):
self._logger.error(message, *args, **kwargs)

def critical(self, message: str, *args, **kwargs):
"""Log a critical level message."""
if self._should_log("CRITICAL"):
self._logger.critical(message, *args, **kwargs)


def set_log_level(level: str) -> None:
"""
Set the plugin's log level.

Valid levels: CRITICAL, ERROR, WARNING, INFO, DEBUG, TRACE

:param level: The log level to set
"""
global _current_log_level
level_upper = level.upper()
if level_upper not in LOG_LEVELS:
raise ValueError(f"Invalid log level: {level}. Must be one of {list(LOG_LEVELS.keys())}")
_current_log_level = level_upper


def get_log_level() -> str:
"""Get the current plugin log level."""
return _current_log_level


# Create the global logger instance
log = PluginLogger()
Loading