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

fix: Make log macro fully compatible with std::format #1189

Merged
merged 1 commit into from
Jun 4, 2024

Conversation

Sliman4
Copy link
Contributor

@Sliman4 Sliman4 commented Jun 3, 2024

This PR makes log! macro 100% compatible with std format!, allowing string interpolation while passing just 1 string literal.

I also noticed that this macro uses format from local scope, now it's prefixed with ::std to make sure it can't be accidentally overridden.

Fixes: #1188

BREAKING CHANGE: let x = "1"; log!(x) doesn't work anymore, and log!("str with no formatting") now allocates, like format!. For logging &str with no additional formatting and no allocations, use env::log_str method instead.

BREAKING CHANGE: `let x = "1"; log!(x)` doesn't work anymore, and `log!("str with no formatting")` now allocates, like `format!`. For logging `&str` with no additional formatting and no allocations, use `env::log_str` method instead.
Copy link
Collaborator

@frol frol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ouch, the breaking change is unfortunate, but it is trivial to fix and I hope nobody actually used this syntax in proper contracts

@frol frol merged commit 289d75f into near:master Jun 4, 2024
15 checks passed
@frol frol mentioned this pull request Jun 4, 2024
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

Successfully merging this pull request may close these issues.

log!("{x}") treats input as a raw string
2 participants