Skip to content

Commit

Permalink
fix(@embark/transaction-logger): Circular JSON log and unknown contra…
Browse files Browse the repository at this point in the history
…ct 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.
  • Loading branch information
emizzle authored and iurimatias committed Jan 9, 2020
1 parent 6be404b commit 5843a8e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion 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';
Expand Down Expand Up @@ -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);
});
Expand Down

0 comments on commit 5843a8e

Please sign in to comment.