2012-06-22 11:31:15 +02:00
|
|
|
|
2012-06-22 09:32:39 +02:00
|
|
|
class FakeLogger(object):
|
|
|
|
def __getattr__(self, key):
|
|
|
|
return lambda *x, **y: None
|
2012-06-22 11:31:15 +02:00
|
|
|
|
|
|
|
|
|
|
|
def set_verbosity_level(logger, verbosity):
|
2012-07-02 18:16:59 +02:00
|
|
|
import logging
|
|
|
|
|
2012-06-22 11:31:15 +02:00
|
|
|
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
|
2012-07-02 18:16:59 +02:00
|
|
|
|