Skip to content

Commit

Permalink
update README with console.log details (gakonst#339)
Browse files Browse the repository at this point in the history
* update README with console.log details

I found this useful, and figured it might be useful for others, so I gave it a quick writeup

* Apply suggestions from code review

Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
  • Loading branch information
wschwab and gakonst authored Dec 30, 2021
1 parent e70361c commit 5654afc
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions forge/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,22 @@ interface Vm {
// Expects an error on next call
function expectRevert(bytes calldata) external;
}
```
### `console.log`


We support the logging functionality from Hardhat's `console.log`.

If you are on a hardhat project, `import hardhat/console.sol` should just work if you use `forge test --hh`.

If no, there is an implementation contract [here](https://github.com/gakonst/foundry/blob/master/evm-adapters/testdata/console.sol). We currently recommend that you copy this contract, place it in your `test` folder, and import it into the contract where you wish to use `console.log`, though there should be more streamlined functionality soon.

Usage follows the same format as [Hardhat](https://hardhat.org/hardhat-network/reference/#console-log):
```solidity
import "./console.sol";
...
console.log(someValue);
```

## Future Features
Expand Down

0 comments on commit 5654afc

Please sign in to comment.