Minor debug logging improvements

This commit is contained in:
mmorrison 2019-01-20 04:21:40 -06:00
parent 9a536b160e
commit 2a87360a0e
4 changed files with 24 additions and 16 deletions

View file

@ -13,7 +13,9 @@ class Logger {
_print(...args) {
try {
const strings = this._convertArgsToStrings(...args);
console.log(...strings);
if (strings.length) {
console.log(...strings);
}
} catch(e) {
console.log("Error while logging: " + e);
}
@ -25,9 +27,9 @@ class Logger {
if (arg instanceof Error) {
out.push(arg.stack);
} else if (arg instanceof Buffer) {
out.push("\n" + HexUtil.debugDump(arg) + "\n");
out.push(HexUtil.debugDump(arg));
} else if (typeof arg == 'function') {
const result = arg.call(undefined, (...args) => out.push(...this._convertArgsToStrings(...args)));
const result = arg.call(undefined, (...args) => this._print(...args));
if (result !== undefined) out.push(...this._convertArgsToStrings(result));
} else {
out.push(arg);