Skip to content

feat: use module names for loggers #136

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 2 commits into from
Jan 14, 2022
Merged

feat: use module names for loggers #136

merged 2 commits into from
Jan 14, 2022

Conversation

datawookie
Copy link
Contributor

Hi!

We've been using this package for around a year now and have really enjoyed how simple it makes submitting queries to the Watson API.

However, we'd like to be able to control the level of logging produced by the library. At present this is difficult since all of the modules what use logging do it via the root logger (so it's impossible to pin-point just what we are turning off).

In this MR I have used the module name for each module that employs logging. This means that clients using the package can now selecting turn logging on or off for this package. This is the behaviour that is implemented in many popular Python packages like requests.

Thanks, Andrew.

@CLAassistant
Copy link

CLAassistant commented Jan 13, 2022

CLA assistant check
All committers have signed the CLA.

@padamstx padamstx changed the title Use module names for loggers feat: use module names for loggers Jan 13, 2022
@padamstx padamstx self-assigned this Jan 13, 2022
@padamstx
Copy link
Member

@datawookie Andrew, thank you for the PR! We'll get this reviewed and let you know about any feedback, etc.

@rmkeezer @pyrooka Hey guys, this seems to be a pretty straightforward PR. Can you give it a look to make sure I didn't miss anything? :)

@padamstx
Copy link
Member

@datawookie Andrew, one question... given these changes, can you briefly describe how one would turn on or off the logging for a specific logger/module? Thanks

Copy link
Member

@padamstx padamstx left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@pyrooka pyrooka left a comment

Choose a reason for hiding this comment

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

Hey @datawookie! The PR looks good overall, I've just requested some code style related changes. I don't want to be too picky, just trying to follow the conventions.

Copy link
Contributor Author

@datawookie datawookie left a comment

Choose a reason for hiding this comment

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

Looks good. Thank you!

@datawookie
Copy link
Contributor Author

Hi @pyrooka, I'm all about conventions, so very happy to apply those changes. Thank you!

@padamstx
Copy link
Member

padamstx commented Jan 13, 2022

@datawookie With your latest changes, the build is now failing during the unti test execution due to some sort of indentation issue. Are you able to build/test cleanly in your local sandbox?
i.e. try this in the root of the project:

make ci

(this is the same command that is run during the Travis build)

Edit: I recommend that you use a virtualenv to avoid polluting your machine with dependencies from this project :)

Comment on lines 43 to 48
logger = logging.getLogger(__name__)


#pylint: disable=too-many-instance-attributes
#pylint: disable=too-many-locals
class BaseService:


#pylint: disable=too-many-instance-attributes
#pylint: disable=too-many-locals
class BaseService:
Copy link
Member

Choose a reason for hiding this comment

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

@datawookie I should have said that my suggestion was invalid in that context, because I wasn't able to select the whole code block.
You can easily fix the duplicated code manually, then check it as @padamstx mentioned.

@datawookie
Copy link
Contributor Author

Hi @pyrooka, ah, crap. No problem. I applied the changes locally and then force pushed. Also changed my commit messages to use conventional commits. Hope that this is all good now. Thanks, Andrew.

@padamstx padamstx self-requested a review January 14, 2022 14:07
Copy link
Member

@padamstx padamstx left a comment

Choose a reason for hiding this comment

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

Just took a fresh look at all the latest changes and still LGTM!

Copy link
Member

@pyrooka pyrooka left a comment

Choose a reason for hiding this comment

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

@datawookie I approve it to avoid the re-review, but there is one more thing to fix. Sorry, if I was confusing!

@datawookie
Copy link
Contributor Author

Hi @pyrooka, I've moved the code. Thanks, Andrew.

@padamstx
Copy link
Member

padamstx commented Jan 14, 2022

@datawookie I think all the code changes look good now, but with your last commit it looks like you added the "nohup.out" file inadvertently. Please remove that then update your branch and we can get this PR merged in. Thanks!

@datawookie
Copy link
Contributor Author

@pyrooka fixed!

@padamstx padamstx removed the request for review from rmkeezer January 14, 2022 16:42
@padamstx padamstx merged commit 36523c8 into IBM:main Jan 14, 2022
ibm-devx-sdk pushed a commit that referenced this pull request Jan 14, 2022
# [3.14.0](v3.13.2...v3.14.0) (2022-01-14)

### Features

* use module names for loggers ([#136](#136)) ([36523c8](36523c8))
@ibm-devx-sdk
Copy link

🎉 This PR is included in version 3.14.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants