mirror of
https://github.com/tribufu/node-gamedig
synced 2026-05-18 09:35:50 +00:00
Minor debug logging improvements
This commit is contained in:
parent
9a536b160e
commit
2a87360a0e
4 changed files with 24 additions and 16 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue