-
Notifications
You must be signed in to change notification settings - Fork 2.6k
docs: update logger coding guidelines #15359
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
base: master
Are you sure you want to change the base?
Conversation
Recommend named logger usage and specify a naming convention.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic idea, I just have one comment on the naming convention:
It seems a bit verbose to me. Usually, I'd like loggers to be feature based not necessarily file based (does that make sense?). I.e. I've already started logging all notebook related logs to notebook
, even if they're in the @theia/plugin-ext
package. I'm not against updating my code, but keep in mind that the name of the logger gets printed to every log being performed in the console. That sounds like a lot of noise to me. It also makes deactivating/activating certain loggers in the config more cumbersome.
What do the others think about this?
I think we need to think logger names from the goals we have with them: in the end, the goal is to turn sections of logging on and off in a convenient way. That requires two things:
If we name loggers based on filenames (or some other "fully qualified classname" 😉 , we can infer the "feature", if we can match rules by something like a regex or glob e.g.
But generally, we should just imagine log names as a set of properties we can match against. On node, would this work?
Also: if we need logging in non-inversify contexts, can we make the inversify stuff generally defer log management to some global service? Kindof like we use contributions to register stuff with a service? |
LGTM, I would add for future sprints, wrapping the logger in the trace event format https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/edit?pli=1&tab=t.0#heading=h.yr4qxyxotyw would help make it readable in trace compass, chrome and others. Here's a reference java implementation. https://github.com/eclipse-tracecompass/trace-event-logger |
@tsmaeder @msujew If I understand you both correctly, then we have a conflict of interest: Whether to name the loggers after their location or the purpose of the code. Both of these make sense to me.
The approaches could also be combined using a scheme like this:
The location could be all kind of schemes like
For example
If we then also support regex configuring, then it's easy to configure for purpose and/or location What are your thoughts? |
|
+1 on doing a purpose + location logger naming and filtering on regex. Again, if we're trying to allow for precise filtering, we could add more loggers with suffixes (for example, with the class name as a suffix) if that component produces output that needs to be either addressed precisely or filtered out. So for me a naming strategy of |
What it does
Recommend named logger usage and specify a naming convention.
Follow-ups
Update all logging use cases in Theia framework
Breaking changes
Attribution
Review checklist
Reminder for reviewers