euscan-ng/euscanwww/djeuscan/processing/__init__.py
volpino 779ccdf5d3 euscanwww: use logging in djeuscan.processing
Signed-off-by: volpino <fox91@anche.no>
2012-06-22 11:31:15 +02:00

32 lines
563 B
Python

import logging
class FakeLogger(object):
def __getattr__(self, key):
return lambda *x, **y: None
def set_verbosity_level(logger, verbosity):
try:
verbosity = int(verbosity)
except (ValueError, TypeError):
return logger
levels = {
0: logging.DEBUG,
1: logging.INFO,
2: logging.WARNING,
3: logging.ERROR,
4: logging.CRITICAL
}
if verbosity < 0:
verbosity = 0
if verbosity > 4:
verbosity = 4
logger.setLevel(levels[verbosity])
return logger