Disable logger from imported module in a custom module

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Disable logger from imported module in a custom module



I usually define my logger in main.py and then I use the same format in all my other custom modules and classes.



However, since I imported the discovery module within MyClass I get lots of logs that I don't want. How can I disable only the discovery logs while keeping all others?



I've tried



main.py


import logging
import MyClass

logging.basicConfig(level = logging.INFO, format = '%(asctime)s:%(levelname)s:%(module)s:%(message)s')
logger = logging.getLogger(__name__)

myc = MyClass.MyClass()
myc.do_something()



MyClass.py


import logging
from googleapiclient import discovery

class MyClass(object):

def __init__(self):

self.logger = logging.getLogger(__name__)

def do_something(self):
# code using discovery



I've tried adding this to MyClass after importing both logging and discovery but it didn't help:


logging.getLogger('discovery').setLevel(logging.WARNING)



These are the logs I'm trying to get rid of:



2018-08-10 16:11:11,702:INFO:discovery:URL being requested: GET
https://www.googleapis.com/discovery/v1/apis/drive/v3/rest 2018-08-10
16:11:11,800:INFO:discovery:URL being requested: GET
https://www.googleapis.com/drive/v3/teamdrives?alt=json





Wrong logger - discovery is not googleapiclient.discovery.
– user2357112
Aug 10 at 20:27


discovery


googleapiclient.discovery





Duh! Thanks, I added that and it worked.
– Victor
Aug 10 at 20:28









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard