Repository navigation
Conversation
`log!`'s first arm took a lone string, checked it with `format!` and
then logged the string itself. That arm predates inline format
arguments: `warn!("failed to load {path}")` compiles, and the check
formats it correctly, but the log shows `failed to load {path}`. An
escaped brace, as in `"{{"`, came out doubled too.
The arm is gone, so a lone string goes through the same `format!` as
a string with arguments after it, and prints as `println!` would.
`test_logs` now logs an inline argument at each level.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`test_logs` printed its messages without checking them, so it passed with the lone-string bug in place. The desktop logger now also records each message under `cfg(test)`, and the test compares them with what `format!` gives, an escaped brace included. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
log!'s first arm matches a string with nothing after it. It checks the string withformat!, throws the result away and logs the string itself. The arm predates inline format arguments, whichformat!accepts, so this compiles and logsfailed to load {path}:An escaped brace comes out doubled too:
warn!("{{}}")logs{{}}rather than{}. macroquad re-exports these macros asmacroquad::logging, so its users hit the same thing.Change
The arm is gone. A string with nothing after it now goes through the same
format!as one with arguments, so it prints asprintln!would.test_logslogs an inline argument at each level and an escaped brace. Undercfg(test), the desktop logger also records each message, and the test checks them.The arm spared those messages an allocation, but the Android, wasm and iOS loggers copy every message into a C string or an
NSStringanyway.Verification
cargo test --features log-impl test_logspasses with this change. With the old arm put back, it fails: the logger getsinfo: {value}at each level and{{value}}, notinfo: 1and{value}.cargo check --features log-implpasses foraarch64-apple-darwin,aarch64-apple-ios,aarch64-apple-tvos,aarch64-linux-androidandwasm32-unknown-unknown.🤖 Generated with Claude Code