From 5654afce162cb90baca8f96ab34202e11db1d505 Mon Sep 17 00:00:00 2001 From: William Schwab <31592931+wschwab@users.noreply.github.com> Date: Thu, 30 Dec 2021 22:56:25 +0200 Subject: [PATCH] update README with console.log details (#339) * 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 --- forge/README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/forge/README.md b/forge/README.md index 9d4b8c2d9..c12e77e72 100644 --- a/forge/README.md +++ b/forge/README.md @@ -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