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

brick should allow bypassing of quoting of log lines #117

Open
aspiers opened this issue Feb 11, 2020 · 1 comment
Open

brick should allow bypassing of quoting of log lines #117

aspiers opened this issue Feb 11, 2020 · 1 comment
Labels
proposal UX Not bugs or features, but areas where the user/developer experience could be better

Comments

@aspiers
Copy link
Contributor

aspiers commented Feb 11, 2020

When debugging via brick, it can be extremely helpful to add logging of multiline statements to the smart contract. For example maybe we want to see a stack trace at the current execution point:

system.print(debug.traceback())

But currently this results in something like this very long line:

INF "stack traceback:\u000a\u0009[string \"0cca71fcf76698693693c6edc703ea42c82494bfafa1b6a14100aabaa7a1afb08f\"]:773: in function 'f'\u000a\u0009[string \"0cca71fcf76698693693c6edc703ea42c82494bfafa1b6a14100aabaa7a1afb08f\"]:49: in function 'cancel'\u000a\u0009[string \"0cca71fcf76698693693c6edc703ea42c82494bfafa1b6a14100aabaa7a1afb08f\"]:794: in function <[string \"0cca71fcf76698693693c6edc703ea42c82494bfafa1b6a14100aabaa7a1afb08f\"]:787>\u000a\u0009[C]: at ?" Contract SystemPrint=AmhUpxjiT8KhQXX6N3QmZMwZJ4FoDzbwFogxnBNNF4SHs1btauXx module=contract 

Even if #113 is fixed, the fact that many characters are escaped makes this very hard to understand. The biggest problem is that newlines are rendered as \u000a, so it's really difficult to visually parse the stacktrace. But it would also be helpful if other characters like " were also not escaped.

I understand that this change would break the convention of one logging event per line, and maybe on a production blockchain that is unacceptable. But in brick when the emphasis is on testing and debugging it is more helpful. So I suggest either we change this for brick, or at least add a new option to brick which disables quoting.

@aspiers
Copy link
Contributor Author

aspiers commented Feb 11, 2020

Here is a very quick and ugly workaround which strips some of the quoting:

brick foo.brick -v -w 2>&1 | perl -pe 's/\\"/"/g; s/\\u00(\w\w)/chr hex $1/ge'

@aspiers aspiers added the UX Not bugs or features, but areas where the user/developer experience could be better label Feb 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal UX Not bugs or features, but areas where the user/developer experience could be better
Projects
None yet
Development

No branches or pull requests

1 participant