harvimt / quamash

Implementation of the PEP 3156 event-loop (asyncio) api using the Qt Event-Loop
BSD 2-Clause "Simplified" License
265 stars 46 forks source link

Control logging #67

Closed thijstriemstra closed 7 years ago

thijstriemstra commented 7 years ago

There's a lot of log statements coming from this library (which I like) but how do I disable these (loggers)?

e.g.

2016-11-23 00:35:43,837 [DEBUG] Running <generator object EmailManager.send_mail.<locals>.send_message at 0x7fa8f4faf518> until complete
2016-11-23 00:35:43,837 [DEBUG] Registering callback <bound method Task._step of <Task pending coro=<EmailManager.send_mail.<locals>.send_message() running at /usr/local/lib/python3.5/asyncio/coroutines.py:204>>> to be invoked with arguments () after 0 second(s)
2016-11-23 00:35:43,837 [DEBUG] Adding callback <Handle Task._step()> with delay 0
2016-11-23 00:35:43,837 [DEBUG] Starting Qt event loop
2016-11-23 00:35:43,839 [DEBUG] Callback timer fired, calling <Handle Task._step()>
2016-11-23 00:35:43,933 [INFO] Email sent!
2016-11-23 00:35:43,933 [DEBUG] Registering callback <function QEventLoop.run_until_complete.<locals>.stop at 0x7fa8f4fbd0d0> to be invoked with arguments (<Task finished coro=<EmailManager.send_mail.<locals>.send_message() done, defined at /usr/local/lib/python3.5/asyncio/coroutines.py:204> result=None>,) after 0 second(s)
2016-11-23 00:35:43,934 [DEBUG] Adding callback <Handle QEventLoop.run_until_complete.<locals>.stop(<Task finishe...> result=None>) at /home/thijs/.virtualenvs/foo/lib/python3.5/site-packages/quamash/__init__.py:262> with delay 0
2016-11-23 00:35:43,934 [DEBUG] Callback timer fired, calling <Handle QEventLoop.run_until_complete.<locals>.stop(<Task finishe...> result=None>) at /home/thijs/.virtualenvs/foo/lib/python3.5/site-packages/quamash/__init__.py:262>
2016-11-23 00:35:43,934 [DEBUG] Stopping event loop...
2016-11-23 00:35:43,934 [DEBUG] Stopped event loop
2016-11-23 00:35:43,934 [DEBUG] Qt event loop ended with result 0
2016-11-23 00:35:43,934 [DEBUG] Future <Task finished coro=<EmailManager.send_mail.<locals>.send_message() done, defined at /usr/local/lib/python3.5/asyncio/coroutines.py:204> result=None> finished running
harvimt commented 7 years ago
logging.getLogger('quamash').setLevel(logging.ERROR)

should drastically reduce logging. Standard logging configuration applies once you get the logger with logging.getLogger.