From 5843a8e03e0d72fe5d9f824f5369ab724d2ef5b3 Mon Sep 17 00:00:00 2001 From: emizzle Date: Mon, 6 Jan 2020 14:10:55 +1100 Subject: [PATCH] fix(@embark/transaction-logger): Circular JSON log and unknown contract log level ## Issue Transaction logs for contracts that were unknown to Embark (ie not in the dapp) would often log super large objects (filling the terminal) that were not formatted with spaces so were hard to read without actually be that useful. In addition, occasionally the object logged would throw the error `TypeError: Converting circular structure to JSON`. ## Fix Set the log level for transaction logs that are not from a known contract to `debug`, so that they do not flood the terminal with often usused information. Use `util.inspect` to print the transaction log instead of `JSON.stringify` to prevent circular structure errors. --- packages/plugins/transaction-logger/src/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/plugins/transaction-logger/src/index.js b/packages/plugins/transaction-logger/src/index.js index 10ebf6def..42764d0bf 100644 --- a/packages/plugins/transaction-logger/src/index.js +++ b/packages/plugins/transaction-logger/src/index.js @@ -1,6 +1,7 @@ const async = require('async'); import { __ } from 'embark-i18n'; const Web3 = require('web3'); +const util = require('util'); const { blockchain: blockchainConstants } = require('embark-core/constants'); import { dappPath, hexToNumber } from 'embark-utils'; @@ -169,7 +170,7 @@ export default class TransactionLogger { const contract = this.addressToContract[address]; if (!contract) { - this.logger.info(`Contract log for unknown contract: ${JSON.stringify(args)}`); + this.logger.debug(`Contract log for unknown contract: ${util.inspect(args)}`); return this._getContractsList((contractsList) => { this.addressToContract = getAddressToContract(contractsList, this.addressToContract); });