-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add configure method, to enable users to own a valid configured instance before calling set_boxed_logger
#88
Conversation
I think it definitely makes sense to be able to wrap SimpleLogger like this. I wonder if it might make sense to break out the specific things (†I guess the existing |
Hi, thank you for answering ! Should I also include a |
Yes - it's definitely worth including something in the README about this or adding an example in the examples directory :) I think it might make sense to rename |
Hi ! I'll try and add something to the README. I'm hesitant to rename Let's decide on a suitable API to be sure that I understand you. Are you suggesting the user do: let mut logger = SimpleLogger::new();
set_up_color_terminal();
let max_level = logger.max_level(); ? And then of course the user has its own code that uses something else as a logger? The current branch state makes the user do: let mut logger = simpleLogger::new();
let max_level = logger.configure(); |
I should add that I'm completely fine if you wanna do those changes yourself of course, if you have a precise idea of what you want |
Yeah, this is exactly what I was thinking – I should have included an example. I see |
(I might get a chance to work on this today, I'll note on this PR if I start doing any work on it.) |
e79cd41
to
1b416f1
Compare
I've updated the PR with your suggestion, and also added a paragraph to the README. Do not hesitate to modify what I've proposed if you think of something better (especially the README part, I'm not sure it's super clear). |
Released as part of 4.3.0, thanks! |
My personal use case is to wrap this logger in my own logger implementation, to be able to catch log calls during testing and react to them. This PR proposes to add a
configure
method to enable users to have a completely configured instance ofSimpleLogger
. Then they can set as global logger something else that might be a wrapper aroundSimpleLogger
.Usage is simply to call
configure
instead ofinit
to finish configuration of an instance ofSimpleLogger
. To avoid code duplication,init
will internally callconfigure
beforeset_boxed_logger
. This means that using the chainsimpleLogger::new().configure().init()
has bad performance and would not be advised. A user would either useconfigure
orinit
.Another implentation would be to add a boolean argument to
init
, but I didn't want to change usual behavior/usage.If this is not interesting, please ignore/close this PR, I'll continue using my fork