SpriteOvO / spdlog-rs

Fast, highly configurable Rust logging crate
https://crates.io/crates/spdlog-rs
Apache License 2.0
107 stars 11 forks source link

[Feature Request] Support formatting parameters in pattern placeholders #56

Open Lancern opened 8 months ago

Lancern commented 8 months ago

spdlog supports specifying text alignment in its pattern flags, see https://github.com/gabime/spdlog/wiki/3.-Custom-formatting#aligning:

Besides, an additional ! can be used to truncate the expanded result if it's too wide:

This feature can be neat sometimes and maybe we could also support this. We may follow the convention of format! and propose the following new pattern placeholder syntax:

placeholder := '{' NAME [ ':' format_spec ] '}'
format_spec := [ [fill] align ] [ ['.'] width ]
fill := CHAR
align := INT
width := INT

Some examples: