Skip to content
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

move logging configuration behind function call #1120

Merged
merged 5 commits into from
Oct 18, 2022

Conversation

untzag
Copy link
Contributor

@untzag untzag commented Oct 17, 2022

After this change users would need to call pymodbus.apply_pymodbus_logging_config() to enable logging as before. This way logs are not injected into my application in an unexpected way.

Happy to change if maintainers wish, or feel free to reject if another option is prefered. A change to this behavior would be really great as my application has carefully formatted logs that will not be parsed correctly due to this injection.

fixes #1119

Copy link
Collaborator

@janiversen janiversen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small but important changes. I like the principle of the PR.

pymodbus/__init__.py Outdated Show resolved Hide resolved
pymodbus/_logging.py Outdated Show resolved Hide resolved
pymodbus/_logging.py Outdated Show resolved Hide resolved
@janiversen
Copy link
Collaborator

You need to add documentation of the call at highlevel in doc/source/library.

@untzag
Copy link
Contributor Author

untzag commented Oct 17, 2022

I personally prefer to keep functionality cleanly separated into different files, which is why I prefer the private file with import * pattern. This is just a preference however so I will defer to maintainers 😄

@janiversen
Copy link
Collaborator

I have no problem having it a file ! but the file contains a public function so naming it _logging is at least confusing. If you just rename the file (and the function to keep the naming standard) I am happy.

@janiversen
Copy link
Collaborator

Please solve the pylint/flake8 problems.

@untzag
Copy link
Contributor Author

untzag commented Oct 17, 2022

Happy to write docs, let me know more details please. You need me to edit doc/source/library/pymodbus.rst?

@janiversen
Copy link
Collaborator

Yeah I think that would be a good place to mention this function.

Please write something like:

  • Use this function to activate debug in the library in a standard format
  • Remark you can activate debug with logging.setlevel("DEBUG") without using this function, but will get another format
  • Please use this function if you create an issue and supply a log, since the maintainers need the information to reproduce/verify your problem.

Do not use my words but the idea :-) I am a hard core programmer and have to torture myself to write documentation.

Thanks for taking care of this.

Copy link
Collaborator

@janiversen janiversen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from the doc, this PR is good to be merged.

@untzag
Copy link
Contributor Author

untzag commented Oct 17, 2022

OK I added a docstring which should be rendered in autodoc and put mention of the function in a few places that made sense to me. Let me know what you think and if I should add more elsewhere.

Copy link
Collaborator

@janiversen janiversen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good apart from the pylint/flake8 error.

@untzag untzag requested a review from janiversen October 18, 2022 13:51
Copy link
Collaborator

@janiversen janiversen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@janiversen janiversen merged commit 428d3f3 into pymodbus-dev:dev Oct 18, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pymodbus.constants interferes with application's logging configuration
2 participants