-
Notifications
You must be signed in to change notification settings - Fork 1k
Central logging #1324
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
Central logging #1324
Conversation
1bc87fd to
a659861
Compare
8e1e30f to
790097a
Compare
|
@janiversen I just started working with pymodbus when I came across an issue that seems related to #1324. When I call main.py, to start the http server, python complains with: In my case the contents of cls.LOG_LEVEL turned out to be the string "INFO", rather than an integer representing a log level of info. |
|
Seems you called the log start function with a string, and not the integer. Might be worth while to make a check and convert if needed. |
|
hmmm there must be some confusion. logging.INFO (the default value for —log) is an integer, when I check it, How did you call main ? |
|
Never mind #1343 solves your issue, it will soon be merged to dev. |
|
Thank you for the fast response |
|
I'm surprised by the changes in this PR. It breaks the assumption that when you properly configure Pythons logging framework to receive a certain level of logs of 'pymodbus' that they will start appearing in your logs. Can you switch back to using |
|
we have never used logging.isenabledfor, so I do not know what you want to switch back to. The local variable we keep in the class is to avoid overhead of calling .getEffectiveLevel() with every log call. We centralized the log calls in a class a while ago, to make logging more consistent and the calls a lot simpler (log do not like f strings), so you might actually have seen it before. Anyhow, pull requests are welcome. |
|
If you talk about the function to activate the logs, it has been there for quite a while, and you actually do not need to call it, to activate logging. You need to call it if you want to submit an issue, because it formats the pymodbus log in a way that enables enables the maintainer to read it automatically. |
|
I'm talking about the LOG_LEVEL class variable I don't understand why it is introduced, as the logging framework is already set up in such a way that it will not process logging calls if there is no handler attached to it (cfr. https://docs.python.org/3/howto/logging.html#logging-flow). As stated on https://docs.python.org/3/howto/logging.html#optimization You already set |
|
let's just say we think that the variable is useful, but looking forward to see a pull request which we can review, |
Simplify logging by providing global log function, that does all the handling (including only creating the f string, when we really want to log something).