Separate debug messages for YouTube

This commit is contained in:
Rafał Dzięgiel
2021-04-08 12:09:42 +02:00
parent ec6157763b
commit c767b3e4b2
2 changed files with 37 additions and 7 deletions

View File

@@ -19,9 +19,19 @@ clapperDebugger.enabled = (
|| G_DEBUG_ENV != null || G_DEBUG_ENV != null
&& G_DEBUG_ENV.includes('Clapper') && G_DEBUG_ENV.includes('Clapper')
); );
const clapperDebug = clapperDebugger.debug;
function debug(msg, levelName) const ytDebugger = new Debug.Debugger('YouTube', {
name_printer: new Ink.Printer({
font: Ink.Font.BOLD,
color: Ink.Color.RED
}),
time_printer: new Ink.Printer({
color: Ink.Color.LIGHT_BLUE
}),
high_precision: true,
});
function _debug(msg, levelName, debuggerName)
{ {
levelName = levelName || 'LEVEL_DEBUG'; levelName = levelName || 'LEVEL_DEBUG';
@@ -30,12 +40,32 @@ function debug(msg, levelName)
msg = msg.message; msg = msg.message;
} }
if(levelName !== 'LEVEL_CRITICAL') if(levelName !== 'LEVEL_CRITICAL') {
return clapperDebug(msg); switch(debuggerName) {
case 'Clapper':
clapperDebugger.debug(msg);
break;
case 'YouTube':
ytDebugger.debug(msg);
break;
}
return;
}
GLib.log_structured( GLib.log_structured(
'Clapper', GLib.LogLevelFlags[levelName], { debuggerName, GLib.LogLevelFlags[levelName], {
MESSAGE: msg, MESSAGE: msg,
SYSLOG_IDENTIFIER: 'clapper' SYSLOG_IDENTIFIER: debuggerName.toLowerCase()
}); });
} }
function debug(msg, levelName)
{
_debug(msg, levelName, 'Clapper');
}
function ytDebug(msg, levelName)
{
_debug(msg, levelName, 'YouTube');
}

View File

@@ -4,7 +4,7 @@ const FileOps = imports.src.fileOps;
const Misc = imports.src.misc; const Misc = imports.src.misc;
const YTDL = imports.src.assets['node-ytdl-core']; const YTDL = imports.src.assets['node-ytdl-core'];
const { debug } = Debug; const debug = Debug.ytDebug;
const InitAsyncState = { const InitAsyncState = {
NONE: 0, NONE: 0,