Skip to content

Conversation

jonathanpallant
Copy link
Contributor

This is a work-in-progress branch investigating whether you can grab the format string at logging time without breaking the 0.3 API.

It adds a new feature called 'no-interning' and a new transport crate called defmt-log which turns the feature on and uses it to grab the format string out of thin air (well, out of a &[u8] that's the same length as the size of a usize).

@Urhengulas Urhengulas marked this pull request as draft January 7, 2025 18:57
@Urhengulas Urhengulas added the pr waits on: author Pull Request requires changes from the author label Jan 8, 2025
This is just an experiment for now.

If the 'no-interning' feature is set, instead of

#[export_name = "{JSON...}"]
static S: u8 = 0;
&S as *const _ as usize

You get:

static S: &'static str = "{JSON...}";
&S as *const _ as usize

Note that I had to change the size of the interned ID from u16 to usize, because with no-interning it's now a pointer to actual data.
This is a work in progress, but it shows how, with the new
`no-interning` feature, a crate can capture defmt log data, including
the actual format string, and render locally.

TODO: Actually parse the format string.
Copy link

cloudflare-workers-and-pages bot commented Mar 3, 2025

Deploying knurling-defmt-book with  Cloudflare Pages  Cloudflare Pages

Latest commit: 90fbd01
Status: ✅  Deploy successful!
Preview URL: https://7cf166b3.knurling-defmt-book.pages.dev
Branch Preview URL: https://add-log-support.knurling-defmt-book.pages.dev

View logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr waits on: author Pull Request requires changes from the author

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants