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

Feature request: console.table #91

Open
PaulRBerg opened this issue Jun 17, 2022 · 6 comments
Open

Feature request: console.table #91

PaulRBerg opened this issue Jun 17, 2022 · 6 comments

Comments

@PaulRBerg
Copy link
Contributor

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.

@ZeroEkkusu
Copy link
Collaborator

ZeroEkkusu commented Jun 23, 2022

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

@PaulRBerg
Copy link
Contributor Author

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

@lucaslain
Copy link

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

@mds1
Copy link
Collaborator

mds1 commented May 12, 2023

Definitely supportive of a console2.table command

@lucaslain
Copy link

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

or Maybe something like console2.rlog32() ?

@PaulRBerg
Copy link
Contributor Author

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

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

No branches or pull requests

4 participants