logging module
darren-martz opened this issue · comments
I have found it difficult to manage the logging output of pytds. A simple line change in pytds.py would help from the following:
logger = logging.getLogger()
changed to
logger = logging.getLogger('tds')
This change would allow the following to work, where today this is ignored and the logs fill with every INFO statement.
logging.getLogger('tds').setLevel(logging.ERROR)
A workaround I used was the following, but its not ideal.
class MyFilter(logging.Filter):
def filter(self, record):
if record.module == "tds" and record.levelname == "INFO":
return False
return True
logging.getLogger().addFilter(MyFilter())
i can just confirm the same issue here.
in pytds/src/pytds/tds.py#L15
just replace :
logger = logging.getLogger()
by
logger = logging.getLogger(__name__)
this will allow projects that use this module to manage the log messages from pytds
Any update on this?? Can we merge the PR associated with the issue. All the info logs are getting in the root and there is no way to stop them at the moment. This simple change would resolve that