fix loggning once more 2

This commit is contained in:
Pavel Murygin 2021-12-08 18:39:58 +03:00
parent 3610ebabc7
commit 658a41b418
2 changed files with 8 additions and 3 deletions

View File

@ -609,9 +609,9 @@ async function runAvmWorker(
toLog.data = dataToString(toLog.data);
if (isInterpretationSuccessful(interpreterResult)) {
log.debug('Interpreter result: ', toLog);
log.debug('Interpreter result: ', w(toLog));
} else {
log.error('Interpreter failed: ', toLog);
log.error('Interpreter failed: ', w(toLog));
}
return interpreterResult;
}

View File

@ -153,7 +153,12 @@ export const checkConnection = async (peer: FluencePeer, ttl?: number): Promise<
};
export function dataToString(data: Uint8Array) {
return new TextDecoder().decode(Buffer.from(data));
const text = new TextDecoder().decode(Buffer.from(data));
try {
return JSON.stringify(JSON.parse(text), null, 4);
} catch {
return text;
}
}
export function w(obj) {