-
-
Notifications
You must be signed in to change notification settings - Fork 31k
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
Error when initializing queue listener from config file #92929
Comments
Could you give a code sample that demonstrates the problem you are seeing? You say something about "line 563", but I have no idea what file you are talking about. I don't think the standard library supports YAML config files anywhere, so your problem may be with a third-party library, not with CPython itself. |
@JelleZijlstra I apologize for not being explicit enough.
So if you were to look at the config_dict, it is in the same order in which they appear in the file.
I should also mention that in order to get the queue listener to work from a config file I made a custom class.
So my config file would look like:
Here's how I'm testing it:
The output is:
The output is an error message: That's what I was explaining before where it is not evaluating the handler if it is alphabetically after the queue listener |
Note that the line in question,
is from 2010 and so predates the change that made dicts keep their defined order, so the sorting was probably done for consistency of order. |
The comment above the line I referenced, indicates it's indeed sorted for consistency and to allow references between handlers. I don't think it can be changed as @djsaroka requested because it would be break existing code, but a doc note may be added (as I haven't been able to find any such note); -- possibly in this section: https://docs.python.org/3.12/library/logging.config.html#dictionary-schema-details |
I think this issue is now out of date as there is now a mechanism for configuring |
I'm loading a logger from a yaml config file.
I noticed that a custom handler that I named "sql" was not initializing.
It is a number of handlers that I have connected to a queue listener that I named "queue_listener" also loading from the file.
I noticed that it left the sql handler as <class 'logging.config.ConvertingDict'> when it added it to the listener instead of resolving it.
So then it would error later with:
process = record.levelno >= handler.level
AttributeError: 'ConvertingDict' object has no attribute 'level'
I tried a multitude of things that did not work so I looked at the logging config.py to see what I was doing wrong with the values I was sending in.
I noticed that in line 563 that it imported the handlers sorted from the config file, ascending alphabetical order.
I tested naming my queue listener, "z_queue_listener" and then everything worked fine.
I think it would probably be best to pull the handlers in order that they are in the config file to avoid this error.
I also tested and reproduced this error with the built in logging handler types as well.
The text was updated successfully, but these errors were encountered: