knurling-rs / defmt

Efficient, deferred formatting for logging on embedded systems
https://defmt.ferrous-systems.com/
Apache License 2.0
750 stars 69 forks source link

Width specifier on log format does not work as expected #846

Closed andresovela closed 4 weeks ago

andresovela commented 1 month ago

It seems that this only happens when you specify the width of something that is formatted with a style or color.

For example, with the log format {[{L}]%bold%10} {s} I would expect to see logs formatted like this:

[DEBUG]    Test

but this is printed instead

[DEBUG] Test

This is because the length of the "[DEBUG]" string is not considered to be 7 as one would expect, but rather something else like 20 something because of the bold and color formatters, which insert unprintable characters in the string.

I'll try to fix this issue, I'm just opening it to keep track of it.