Add a DebugFilter class to weboob/tools/log.py

The browser2 filter debugging is an extra level of "Debug". Since python
logging does not support adding severity levels, we use the Filter class
to remove the lines by default.

Sadly, we cannot pass variable to filters (logging system does not use
the instance passed with addFilter method), so we use to write a filter
for each use case (today: only one...)
This commit is contained in:
Florent 2014-09-26 12:36:12 +02:00
commit 1b0096e6e3

View file

@ -18,7 +18,7 @@
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from collections import defaultdict
from logging import Formatter, getLogger as _getLogger
from logging import Filter, Formatter, getLogger as _getLogger
import sys
@ -49,6 +49,16 @@ def getLogger(name, parent=None):
return logger
class DebugFilter(Filter):
"""
Allow a fine filtering of debug output
"""
def filter(self, record):
if record.name == "b2filters":
return False
return True
class ColoredFormatter(Formatter):
"""
Class written by airmind: