forge-std icon indicating copy to clipboard operation
forge-std copied to clipboard

Feature request: console.table

Open PaulRBerg opened this issue 2 years ago • 6 comments

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:

console.table output

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.

PaulRBerg avatar Jun 17 '22 14:06 PaulRBerg

@mds1 is this smth that should be done in Foundry? (I don't know how the console works under the hood)

ZeroEkkusu avatar Jun 23 '22 16:06 ZeroEkkusu

It should definitely be possible to instruct Forge to selectively format the whitespaces differently based on what log events get emitted.

PaulRBerg avatar May 12 '23 14:05 PaulRBerg

Maybe it can added to console2 if it's going branch off hardhat behavior

lucaslain avatar May 12 '23 16:05 lucaslain

Definitely supportive of a console2.table command

mds1 avatar May 12 '23 16:05 mds1

@PaulRBerg should it follow C printf's format? printf("%-32s", tmp); this works for fixed character arrays

or Maybe something like console2.rlog32() ?

lucaslain avatar May 12 '23 16:05 lucaslain

@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.

PaulRBerg avatar May 12 '23 17:05 PaulRBerg