Print a warning when plugin rank cannot be changed

This commit is contained in:
Rafostar
2021-04-25 22:00:00 +02:00
parent a98ca53dfb
commit e92ad68220
2 changed files with 27 additions and 11 deletions

View File

@@ -31,14 +31,23 @@ const ytDebugger = new Debug.Debugger('YouTube', {
high_precision: true, high_precision: true,
}); });
function _debug(msg, debuggerName) function _logStructured(debuggerName, msg, level)
{
GLib.log_structured(
debuggerName, level, {
MESSAGE: msg,
SYSLOG_IDENTIFIER: debuggerName.toLowerCase()
});
}
function _debug(debuggerName, msg)
{ {
if(msg.message) { if(msg.message) {
GLib.log_structured( _logStructured(
debuggerName, GLib.LogLevelFlags.LEVEL_CRITICAL, { debuggerName,
MESSAGE: msg.message, msg.message,
SYSLOG_IDENTIFIER: debuggerName.toLowerCase() GLib.LogLevelFlags.LEVEL_CRITICAL
}); );
return; return;
} }
@@ -55,10 +64,15 @@ function _debug(msg, debuggerName)
function debug(msg) function debug(msg)
{ {
_debug(msg, 'Clapper'); _debug('Clapper', msg);
} }
function ytDebug(msg) function ytDebug(msg)
{ {
_debug(msg, 'YouTube'); _debug('YouTube', msg);
}
function warn(msg)
{
_logStructured('Clapper', msg, GLib.LogLevelFlags.LEVEL_WARNING);
} }

View File

@@ -6,7 +6,7 @@ const YouTube = imports.src.youtube;
const { PlaylistWidget } = imports.src.playlist; const { PlaylistWidget } = imports.src.playlist;
const { WebApp } = imports.src.webApp; const { WebApp } = imports.src.webApp;
const { debug } = Debug; const { debug, warn } = Debug;
const { settings } = Misc; const { settings } = Misc;
let WebServer; let WebServer;
@@ -119,8 +119,10 @@ class ClapperPlayer extends GstClapper.Clapper
{ {
const gstRegistry = Gst.Registry.get(); const gstRegistry = Gst.Registry.get();
const feature = gstRegistry.lookup_feature(name); const feature = gstRegistry.lookup_feature(name);
if(!feature) if(!feature) {
return debug(`plugin unavailable: ${name}`); warn(`cannot change rank of unavailable plugin: ${name}`);
return;
}
const oldRank = feature.get_rank(); const oldRank = feature.get_rank();
if(rank === oldRank) if(rank === oldRank)