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

Use a module-level logger instead of the root logger #4

Merged
merged 1 commit into from
May 16, 2024

Conversation

cbates8
Copy link
Contributor

@cbates8 cbates8 commented May 16, 2024

Update logging config to create a logger based on __name__ rather than using the root logger. This way, users who import public_ip will be able to interact with the package's logger.

For example, let's say a user has their own logger configured, and for debugging purposes they only want to see logging messages generated by their script. The following snippet would prevent any debug or info level logging messages from the public_ip package being output to the console.

import logging

import public_ip

logging.getLogger("public_ip").setLevel(logging.WARNING)

This PR also updates logging level to use debug rather than info.

Create logger using `__name__` to avoid using root logger.
Update logging level to `debug` instead of `info`.
@vterron vterron changed the title Use Logger Based on __name__ Instead of Root Logger Use a module-level logger instead of the root logger May 16, 2024
@vterron
Copy link
Owner

vterron commented May 16, 2024

Thank you! And thanks also for the detailed description.

@vterron vterron merged commit cb14609 into vterron:master May 16, 2024
1 check passed
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