-
Notifications
You must be signed in to change notification settings - Fork 109
MNT: Set log default handler to WARN #1140
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
Conversation
|
I was thinking we would do this in NSLS-II/nslsii#49. I think leaving the default to |
Codecov Report
@@ Coverage Diff @@
## master #1140 +/- ##
==========================================
+ Coverage 89.32% 89.38% +0.05%
==========================================
Files 51 51
Lines 8552 8553 +1
==========================================
+ Hits 7639 7645 +6
+ Misses 913 908 -5
Continue to review full report at Codecov.
|
|
On second though, we may also want to expose the level here. |
|
👍 to adding |
|
I think exposing RE.log.setLevel('DEBUG')I immediately see log messages. With this change, what's the easiest way to get that functionality? |
|
For what it's worth I find that it is best practice to always set the level on the handler. By setting If this is agreed upon it seems like |
That's a solid point and a major shortcoming of what we currently recommend and make easy in bluesky, ophyd, and caproto. I think we want:
We need to settle on a good recommendation for how users should do (2) without interfering with (1). Our current recommendation -- adjust the levels of the loggers like
I don't think this is quite right either. set_handler(level='DEBUG')
pv.log.addHandler(caproto.current_handler)(I'm using caproto for this argument because it's fine-grained logs make it easy to imagine practical, interesting examples.) But then that prompts the question of how to get DEBUG logs from some component and INFO logs from a different component. Perhaps instead of adding pv1.log.addHandler(caproto.current_handler.debug)
pv1.context.addHandler(caproto.current_handler.info)That could potentially be elided with a convenience method that knows about the global handlers: pv1.handle_logs('DEBUG')
pv1.context.handle_logs('DEBUG') |
This is correct, think my initial suggestion was off base. What I really was thinking of is, wasn't there some
I kind of like this ... you could even start adding logs to the family of handlers automatically in your debug mode for obj in RE._obj_seen:
if hasattr(obj, 'log'):
for handler in RE.handlers:
obj.log.adddHandler(handler) |
Co-Authored-By: ke-zhang-rd <[email protected]>
|
@teddyrendahl I don't want to rule out the possibility that you might be "going crazy" :- D but you are corrent, there is Usability aside, our viable options seem to be:
(1) is a nonstarter because it would block our ability to run always-on Big Brother loggers in the background (e.g. for Elastic). The loggers themselves must be left at NOTSET.
That's a very interesting idea. I would like to avoid adding a "BLUESKY DEBUG MODE" per se, but I like what your code illustrates: the RunEngine always propagates its logging handlers (if any) to each Per @klauer's thoughts here, we should first make a list of scenarios and then evaluate if the proposed scheme(s) make them easy/possible for the user to implement. Here are some ideas.
I have chosen these because I believe only one of them (the second one) is even possible currently. I would like to see a demonstration that they are possible by implementing the "SimpleNamespace of handlers" along with some handler-propagation code along the lines of @teddyrendahl's code snippet. Then we can begin a second discussion around adding new API to make the usage easier in the spirit of |
Do you see every library having their own family? |
|
I think ignoring the existence of Take, for example, a caproto client with a PV. Its client PV could have a The logger name-based method works when all of the information one needs to put a message in a bucket is in the logger name itself. Additionally, the howto linked above even states to not do what we are doing (or proposing to do): Even if the filter argument above isn't terribly compelling, I can't see a scenario in which additional information tacked on by LoggingAdapters could ever possibly be a bad thing. |
|
Having hashed out these ideas caproto and adopted the good suggestions above --- minus my eccentric "family of handlers" suggestion which fortunately never saw the light of day :-D --- we are finally circling back to bluesky to apply those ideas here. See #1185. |
Description
Let user's log handler has WARNING as default
Motivation and Context
There are two groups of handdler. One is user's file/stdout handler, One is elastic handler. Both could be independently. Here user's handler is updated to use ERROR as default and allow customized.
How Has This Been Tested?