diff --git a/src/debug.js b/src/debug.js index 2f7d2e14..81b6b063 100644 --- a/src/debug.js +++ b/src/debug.js @@ -31,41 +31,34 @@ const ytDebugger = new Debug.Debugger('YouTube', { high_precision: true, }); -function _debug(msg, levelName, debuggerName) +function _debug(msg, debuggerName) { - levelName = levelName || 'LEVEL_DEBUG'; - if(msg.message) { - levelName = 'LEVEL_CRITICAL'; - msg = msg.message; - } - - if(levelName !== 'LEVEL_CRITICAL') { - switch(debuggerName) { - case 'Clapper': - clapperDebugger.debug(msg); - break; - case 'YouTube': - ytDebugger.debug(msg); - break; - } + GLib.log_structured( + debuggerName, GLib.LogLevelFlags.LEVEL_CRITICAL, { + MESSAGE: msg.message, + SYSLOG_IDENTIFIER: debuggerName.toLowerCase() + }); return; } - GLib.log_structured( - debuggerName, GLib.LogLevelFlags[levelName], { - MESSAGE: msg, - SYSLOG_IDENTIFIER: debuggerName.toLowerCase() - }); + switch(debuggerName) { + case 'Clapper': + clapperDebugger.debug(msg); + 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'); } diff --git a/src/misc.js b/src/misc.js index 999b28bb..87e30d4a 100644 --- a/src/misc.js +++ b/src/misc.js @@ -131,7 +131,7 @@ function getFileFromLocalUri(uri) const file = Gio.file_new_for_uri(uri); 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; } diff --git a/src/player.js b/src/player.js index 1e5ca55e..44e339ce 100644 --- a/src/player.js +++ b/src/player.js @@ -448,7 +448,7 @@ class ClapperPlayer extends PlayerBase _onPlayerWarning(player, error) { - debug(error.message, 'LEVEL_WARNING'); + debug(error.message); } _onPlayerError(player, error) diff --git a/src/widget.js b/src/widget.js index 37537981..fbace202 100644 --- a/src/widget.js +++ b/src/widget.js @@ -283,7 +283,7 @@ class ClapperWidget extends Gtk.Grid if(currStream && type !== 'subtitle') { const caps = currStream.get_caps(); - debug(`${type} caps: ${caps.to_string()}`, 'LEVEL_INFO'); + debug(`${type} caps: ${caps.to_string()}`); } if(type === 'video') { const isShowVis = (parsedInfo[`${type}Tracks`].length === 0);