Progressive count of debug messages to better trace asynchronous execution.

This commit is contained in:
hackademix 2019-10-21 23:18:18 +02:00
parent c1b3922de1
commit 384b4b7423
1 changed files with 4 additions and 1 deletions

View File

@ -1,13 +1,16 @@
{
let PREFIX = `[${browser.runtime.getManifest().name}]`;
let debugCount = 0;
function log(msg, ...rest) {
console.log(`${PREFIX} ${msg}`, ...rest);
}
function debug(msg, ...rest) {
console.debug(`${PREFIX} ${msg}`, ...rest);
console.debug(`${PREFIX}:${debugCount++} ${msg}`, ...rest);
}
function error(e, msg, ...rest) {
console.error(`${PREFIX} ${msg}`, ...rest, e, e.message, e.stack);
}