forge-std
forge-std copied to clipboard
Feature request: console.table
In JavaScript, console.table is a very useful utility that pretty prints the input data.
Example:
console.table(["apples", "oranges", "bananas"]);
You would get something like this in the console:
Many times I find myself adding empty spaces to my Solidity console.log
statements just so that I can see the outputs aligned on the vertical axis.
It would be nice to have a helper function that creates a table with ASCII characters (e.g. -
) and auto-indents the outputs for us.
@mds1 is this smth that should be done in Foundry? (I don't know how the console
works under the hood)
It should definitely be possible to instruct Forge to selectively format the whitespaces differently based on what log events get emitted.
Maybe it can added to console2
if it's going branch off hardhat behavior
Definitely supportive of a console2.table
command
@PaulRBerg should it follow C printf's format? printf("%-32s", tmp);
this works for fixed character arrays
or Maybe something like console2.rlog32()
?
@lucaslain I honestly don't mind either way. Just having the feature implemented (in whichever way is simpler) would be a huge boon for the Foundry debugging UX.