-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
New logging system (addresses #5874) #5921
Conversation
This is a great initiative! I didn't look in every detail, but it generally looks good and gives us a basis for further discussions. Backwards compatibility is no issue before 1.0 is release. But the question is rather, should the current, simple logger functionality be provided in the future as well? It could certainly be done by providing a simple API for singular Logger use. But I don't know about use cases... if there are any, it can be re-added later. For now it would probably be best to make a clear cut. A few notes:
|
@straight-shoota, thanks for the feedback.
|
Ad 1) I didn't mean fetching a cached object. Ad 2) There are probable use cases where you want to format a log record but not write it to an IO (send formatted log records as UDP messages). It would certainly be possible to use an IO wrapper for such an Adapter, but that's just bloating things up and defeats the purpose. Ad 3) A record also simplifies usage in an adapter/formatter handlers. And it should also have serialization (JSON/YAML mapping) - but that can come in a later PR. |
I really think we should have a longer think and finalise design in #5874 before we put too much effort into this PR |
@RX14 Agreed, I just wanted to put something down on paper (figuratively) for the purposes of discussion. I don't mind redoing things if this turns out not to be what we want. |
Closing in favor of #6901 |
Here's my first stab at a better
Logger
class for the standard library as discussed in #5874. Control goes fromLogger
->Handler
->Adapter
, whereLogger
stores a class name and provides user-friendly methods,Handler
filters by severity, andAdapter
formats the message to an IO.One detail I wasn't sure whether to address - how much do we care about backwards compatibility? As-is this breaks 100% of programs using
Logger
, but I can add a slightly ugly constructor that will preserve some of the simpler use cases.