log html instead of info

pull/3058/head
yann300 2 years ago committed by Aniket
parent 16cedb3494
commit 649efccf26
  1. 32
      apps/remix-ide/src/blockchain/blockchain.js

@ -674,22 +674,24 @@ export class Blockchain extends Plugin {
const hhlogs = await this.web3().eth.getHHLogsForTx(txResult.transactionHash) const hhlogs = await this.web3().eth.getHHLogsForTx(txResult.transactionHash)
if (hhlogs && hhlogs.length) { if (hhlogs && hhlogs.length) {
let finalLogs = '<b>console.log:</b>\n' let finalLogs = <div><div><b>console.log:</b></div>
for (const log of hhlogs) { {
let formattedLog hhlogs.map((log) => {
// Hardhat implements the same formatting options that can be found in Node.js' console.log, let formattedLog
// which in turn uses util.format: https://nodejs.org/dist/latest-v12.x/docs/api/util.html#util_util_format_format_args // Hardhat implements the same formatting options that can be found in Node.js' console.log,
// For example: console.log("Name: %s, Age: %d", remix, 6) will log 'Name: remix, Age: 6' // which in turn uses util.format: https://nodejs.org/dist/latest-v12.x/docs/api/util.html#util_util_format_format_args
// We check first arg to determine if 'util.format' is needed // For example: console.log("Name: %s, Age: %d", remix, 6) will log 'Name: remix, Age: 6'
if (typeof log[0] === 'string' && (log[0].includes('%s') || log[0].includes('%d'))) { // We check first arg to determine if 'util.format' is needed
formattedLog = format(log[0], ...log.slice(1)) if (typeof log[0] === 'string' && (log[0].includes('%s') || log[0].includes('%d'))) {
} else { formattedLog = format(log[0], ...log.slice(1))
formattedLog = log.join(' ') } else {
} formattedLog = log.join(' ')
finalLogs = finalLogs + '&emsp;' + formattedLog + '\n' }
} return <div>{formattedLog}</div>
})}
</div>
_paq.push(['trackEvent', 'udapp', 'hardhat', 'console.log']) _paq.push(['trackEvent', 'udapp', 'hardhat', 'console.log'])
this.call('terminal', 'log', { type: 'info', value: finalLogs }) this.call('terminal', 'logHtml', finalLogs)
} }
execResult = await this.web3().eth.getExecutionResultFromSimulator(txResult.transactionHash) execResult = await this.web3().eth.getExecutionResultFromSimulator(txResult.transactionHash)
if (execResult) { if (execResult) {

Loading…
Cancel
Save