Fix some error messages not being displayed

This commit is contained in:
Rafał Dzięgiel
2021-04-09 18:49:44 +02:00
parent dafa2cfdf5
commit d9939a94c2
4 changed files with 21 additions and 28 deletions

View File

@@ -31,41 +31,34 @@ const ytDebugger = new Debug.Debugger('YouTube', {
high_precision: true, high_precision: true,
}); });
function _debug(msg, levelName, debuggerName) function _debug(msg, debuggerName)
{ {
levelName = levelName || 'LEVEL_DEBUG';
if(msg.message) { if(msg.message) {
levelName = 'LEVEL_CRITICAL'; GLib.log_structured(
msg = msg.message; debuggerName, GLib.LogLevelFlags.LEVEL_CRITICAL, {
} MESSAGE: msg.message,
SYSLOG_IDENTIFIER: debuggerName.toLowerCase()
if(levelName !== 'LEVEL_CRITICAL') { });
switch(debuggerName) {
case 'Clapper':
clapperDebugger.debug(msg);
break;
case 'YouTube':
ytDebugger.debug(msg);
break;
}
return; return;
} }
GLib.log_structured( switch(debuggerName) {
debuggerName, GLib.LogLevelFlags[levelName], { case 'Clapper':
MESSAGE: msg, clapperDebugger.debug(msg);
SYSLOG_IDENTIFIER: debuggerName.toLowerCase() break;
}); case 'YouTube':
ytDebugger.debug(msg);
break;
}
} }
function debug(msg, levelName) function debug(msg)
{ {
_debug(msg, levelName, 'Clapper'); _debug(msg, 'Clapper');
} }
function ytDebug(msg, levelName) function ytDebug(msg)
{ {
_debug(msg, levelName, 'YouTube'); _debug(msg, 'YouTube');
} }

View File

@@ -131,7 +131,7 @@ function getFileFromLocalUri(uri)
const file = Gio.file_new_for_uri(uri); const file = Gio.file_new_for_uri(uri);
if(!file.query_exists(null)) { if(!file.query_exists(null)) {
debug(`file does not exist: ${file.get_path()}`, 'LEVEL_WARNING'); debug(new Error(`file does not exist: ${file.get_path()}`));
return null; return null;
} }

View File

@@ -448,7 +448,7 @@ class ClapperPlayer extends PlayerBase
_onPlayerWarning(player, error) _onPlayerWarning(player, error)
{ {
debug(error.message, 'LEVEL_WARNING'); debug(error.message);
} }
_onPlayerError(player, error) _onPlayerError(player, error)

View File

@@ -283,7 +283,7 @@ class ClapperWidget extends Gtk.Grid
if(currStream && type !== 'subtitle') { if(currStream && type !== 'subtitle') {
const caps = currStream.get_caps(); const caps = currStream.get_caps();
debug(`${type} caps: ${caps.to_string()}`, 'LEVEL_INFO'); debug(`${type} caps: ${caps.to_string()}`);
} }
if(type === 'video') { if(type === 'video') {
const isShowVis = (parsedInfo[`${type}Tracks`].length === 0); const isShowVis = (parsedInfo[`${type}Tracks`].length === 0);