Skip to content

Remove root logger configuration #6

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

Merged
merged 3 commits into from
May 19, 2021
Merged

Remove root logger configuration #6

merged 3 commits into from
May 19, 2021

Conversation

DarkAce65
Copy link
Contributor

Just found this library and started implementing it in an app I'm building - thanks for writing this! One thing I ran into was that the library sets a configuration for the root logger to log at the debug level and propagates to all other loggers. This resulted in other imported libraries also logging at the debug level (which I didn't want).

I found this section in the official documentation that recommends against calling logging.basicConfig in libraries and letting the application configure logging. (Which I found from this SO answer).

Let me know what you think!

@@ -223,6 +221,8 @@ def main(module: str, output: str, json2ts_cmd: str = "json2ts") -> None:
"""
CLI entrypoint to run :func:`generate_typescript_defs`
"""
logging.basicConfig(level=logging.DEBUG, format="%(asctime)s %(message)s")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moving this here makes it so calling pydantic2ts will still print debug logs but importing generate_typescript_defs won't print by default

Copy link
Owner

Choose a reason for hiding this comment

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

Thank you! Doing the work for me AND teaching me something very useful/relevant, I can't ask for more than that 😛

But I do really appreciate it, and your solution makes sense -- merging this in now and then I'll release it along with a few other minor changes

@phillipdupuis phillipdupuis merged commit a8f182d into phillipdupuis:master May 19, 2021
@DarkAce65 DarkAce65 deleted the remove-logging-configuration branch June 4, 2021 02:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants