Drakulix / simplelog.rs

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

[Suggestion] Make `ConfigBuilder` return itself #93

Open alexmozaidze opened 2 years ago

alexmozaidze commented 2 years ago

There's a thing in Rust called builder pattern which is super convinient to build a struct in-place, ConfigBuilder, however, doesn't do that, it instead needs a mutable reference, can you add methods to construct ConfigBuilder in-place? I also think that reading ConfigBuilder docs is a bit of a pain when every option starts with set_, it makes it harder to read.

imxood commented 2 years ago

ConfigBuilder's functions should return self, this will be especially convenient to use ConfigBuilder::new().set_time_offset_to_local()

It doesn't need written two extra lines:

let mut builder = ConfigBuilder::new();
builder.set_time_offset_to_local()
... builder ...
imxood commented 2 years ago

Change ConfigBuilder return itself #103