Drakulix / simplelog.rs

Simple Logging Facility for Rust
https://docs.rs/simplelog/
Apache License 2.0
423 stars 71 forks source link

Padding module name #79

Closed tekjar closed 2 years ago

tekjar commented 2 years ago

Is it possible to pad module names? Alignment is kinda screwed up (because of different module names) when I log different modules

image

Sometimes I also don't need full module path. Just module name would be sufficient. Is it possible to customize this?

Drakulix commented 2 years ago

Padding the module name would require to know all possible module names in advance to compute the maximum length of the module string. This is currently not something log (and therefor simplelog) supports.

But parsing the module path and just logging the module name could be done. I would accept pull requests adding this feature.

tekjar commented 2 years ago

Isn't passing padding as user input and overflowing if a module name doesn't fit not an option? User will know what's the maximum module length and set padding accordingly

Drakulix commented 2 years ago

Isn't passing padding as user input and overflowing if a module name doesn't fit not an option? User will know what's the maximum module length and set padding accordingly

That could also work, I guess, and would be conceptually very similar to the existing thread padding:

But a ModulePadding type would use the provided usize as an upper bound rather than an amount of spaces.

I would accept a PR for that proposal (or better in addition to shortening the module path) as well.

tekjar commented 2 years ago

Hi @Drakulix . Created a PR for this

Drakulix commented 2 years ago

Feel free to re-open if anyone wants to extend this, but #85 added basic padding. Thanks @tekjar