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

Add logd<T>(a: T) as a reporting/printing mechanism #823

Closed
emilyaherbert opened this issue Feb 22, 2022 · 2 comments · Fixed by #1572
Closed

Add logd<T>(a: T) as a reporting/printing mechanism #823

emilyaherbert opened this issue Feb 22, 2022 · 2 comments · Fixed by #1572
Labels
enhancement New feature or request lib: std Standard library P: critical Should be looked at before anything else

Comments

@emilyaherbert
Copy link
Contributor

Per discussion on Slack, it would be nice to have println! and print! for devs 😄

Per @nfurfaro:

Would be nice to integrate this with the tooling, so that println! in a contract would work for debugging on a local node (like hardhat’s console.sol , and would function like the Rust println! in a script.

It was such a win for debugging Solidity when console.sol was introduced.

ideally, forc could strip out these println! s when compilling for release, and leave them in for debugging

no, and that’s why solidity doesn’t have it. Hardhat added a special console.sol contract you could inherit from which added the capability, but only when running against a local hardhat node.

@adlerjohn adlerjohn added compiler General compiler. Should eventually become more specific as the issue is triaged enhancement New feature or request labels Feb 22, 2022
@mohammadfawaz mohammadfawaz added the language feature Core language features visible to end users label Mar 15, 2022
@adlerjohn
Copy link
Contributor

adlerjohn commented Mar 31, 2022

This can largely be reproduced with LOGD

Steps:

With all that together you can have a generic logd<T>(a: T) function in the stdlib that logs an arbitrary stack type. Then you just print out all the logs in your Rust test.

@emilyaherbert emilyaherbert changed the title Add println! and print! Add logd<T>(a: T) as a reporting/printing mechanism Apr 14, 2022
@emilyaherbert emilyaherbert added the P: critical Should be looked at before anything else label Apr 14, 2022
@emilyaherbert
Copy link
Contributor Author

emilyaherbert commented Apr 14, 2022

@adlerjohn via slack:

println! can largely be replaced by logd, but the SDK needs to support that. We should start with that, and if it's insufficient then implement some sort of standardization around println! so that the SDK knows "oh this LOGD is a print"

@adlerjohn adlerjohn added lib: std Standard library and removed compiler General compiler. Should eventually become more specific as the issue is triaged language feature Core language features visible to end users labels May 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request lib: std Standard library P: critical Should be looked at before anything else
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants