Skip to content

Commit 5843a8e

Browse files
emizzleiurimatias
authored andcommitted
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.
1 parent 6be404b commit 5843a8e

File tree

1 file changed

+2
-1
lines changed
  • packages/plugins/transaction-logger/src

1 file changed

+2
-1
lines changed

packages/plugins/transaction-logger/src/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const async = require('async');
22
import { __ } from 'embark-i18n';
33
const Web3 = require('web3');
4+
const util = require('util');
45

56
const { blockchain: blockchainConstants } = require('embark-core/constants');
67
import { dappPath, hexToNumber } from 'embark-utils';
@@ -169,7 +170,7 @@ export default class TransactionLogger {
169170

170171
const contract = this.addressToContract[address];
171172
if (!contract) {
172-
this.logger.info(`Contract log for unknown contract: ${JSON.stringify(args)}`);
173+
this.logger.debug(`Contract log for unknown contract: ${util.inspect(args)}`);
173174
return this._getContractsList((contractsList) => {
174175
this.addressToContract = getAddressToContract(contractsList, this.addressToContract);
175176
});

0 commit comments

Comments
 (0)