Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for console.log #480

Open
iamdefinitelyahuman opened this issue May 3, 2020 · 11 comments
Open

Add support for console.log #480

iamdefinitelyahuman opened this issue May 3, 2020 · 11 comments
Labels
enhancement New feature or request

Comments

@iamdefinitelyahuman
Copy link
Member

Overview

Brownie should support console.log as implemented by Buidler

Specification

  1. Access to the functionality comes from an import: import "@nomiclabs/buidler/console.sol";
  2. The imported contract is available at: nomiclabs/buidler/packages/buidler-core/console.sol
  3. console is a library. log sends a call to an empty account with a particular signature depending on the param type(s) given. It will be possible to extract these from the debug_traceTransaction output.

Considerations

  1. How to handle importing console.sol without reliance on NPM? The solution will likely require expanding the brownie package manager.
  2. The implementation must produce consistent results with buidler. Should examine their test cases around this and write similar ones for Brownie.
@iamdefinitelyahuman iamdefinitelyahuman added the enhancement New feature or request label May 3, 2020
@alcuadrado
Copy link

Forgot to mention that https://tenderly.dev/ implements the same console.log functionality.

@aet00
Copy link

aet00 commented Jul 2, 2021

Has this feature been implemented now? @iamdefinitelyahuman

@iamdefinitelyahuman
Copy link
Member Author

Not yet, need #1043 first

@anticlimactic
Copy link

how about now? because it looks like #1043 has been merged. @iamdefinitelyahuman

@Keref
Copy link

Keref commented May 26, 2022

The issue is still open so I comment how I got it to work: I just installed hardhat and dependencies normally with npm, then I run my network with npx hardhat node --network hardhat.

The solidity import uses absolute path import "../node_modules/hardhat/console.sol"; . It works and I get the console logs in the hardhat console when I do testing with brownie.

@zmeghji
Copy link

zmeghji commented Jun 2, 2022

Emitting events with the data you want to log could be an alternative if you don't want to use hardhat:
https://permanentiteration.com/console-log-alternative-for-brownie/

@Keref
Copy link

Keref commented Jun 3, 2022

Emitting events don't work if the tx reverts.
Also don't spam your blog posts here.

Emitting events with the data you want to log could be an alternative if you don't want to use hardhat: https://permanentiteration.com/console-log-alternative-for-brownie/

@BlinkyStitt
Copy link
Collaborator

Actually I am pretty sure that there's still logs up to the revert.

@Keref
Copy link

Keref commented Jun 3, 2022

My bad: with eth-brownie indeed tx.events will return the events of a failed tx too

@Hugo0
Copy link

Hugo0 commented Aug 9, 2022

Emitting events with the data you want to log could be an alternative if you don't want to use hardhat: https://permanentiteration.com/console-log-alternative-for-brownie/

I actually appreciate the blogpost spam, thanks. Good workaround @zmeghji <3

@0xm4ud
Copy link

0xm4ud commented Apr 13, 2023

Submitted a PR with the implemented feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

9 participants