def setup_logging(filename): #from twisted.python import log #from twisted.internet import defer #import sys #defer.setDebugging(True) #log.startLogging(sys.stdout) levels = os.getenv('CALVIN_TESTS_LOG_LEVELS', "").split(':') set_file(filename) if not levels: get_logger().setLevel(logging.INFO) return for level in levels: module = None if ":" in level: module, level = level.split(":") if level == "CRITICAL": get_logger(module).setLevel(logging.CRITICAL) elif level == "ERROR": get_logger(module).setLevel(logging.ERROR) elif level == "WARNING": get_logger(module).setLevel(logging.WARNING) elif level == "INFO": get_logger(module).setLevel(logging.INFO) elif level == "DEBUG": get_logger(module).setLevel(logging.DEBUG) elif level == "ANALYZE": get_logger(module).setLevel(5)
def set_loglevel(levels, filename): from calvin.utilities.calvinlogger import get_logger, set_file global _log if filename: set_file(filename) _log = get_logger(__name__) if not levels: get_logger().setLevel(logging.INFO) return for level in levels: module = None if ":" in level: module, level = level.split(":") if level == "CRITICAL": get_logger(module).setLevel(logging.CRITICAL) elif level == "ERROR": get_logger(module).setLevel(logging.ERROR) elif level == "WARNING": get_logger(module).setLevel(logging.WARNING) elif level == "INFO": get_logger(module).setLevel(logging.INFO) elif level == "DEBUG": get_logger(module).setLevel(logging.DEBUG) elif level == "ANALYZE": get_logger(module).setLevel(5)
def pytest_configure(config): filename = config.getoption("logfile") if filename: calvinlogger.set_file(filename) levels = config.getoption("loglevel") for level in levels: module = None if ":" in level: module, level = level.split(":") print("Setting debuglevel %s on module %s" % (level, module)) if level == "CRITICAL": calvinlogger.get_logger(module).setLevel(logging.CRITICAL) elif level == "ERROR": calvinlogger.get_logger(module).setLevel(logging.ERROR) elif level == "WARNING": calvinlogger.get_logger(module).setLevel(logging.WARNING) elif level == "INFO": calvinlogger.get_logger(module).setLevel(logging.INFO) elif level == "DEBUG": calvinlogger.get_logger(module).setLevel(logging.DEBUG) elif level == "ANALYZE": calvinlogger.get_logger(module).setLevel(5) # TODO: add func to set any argument from here also from calvin.utilities import calvinconfig _conf = calvinconfig.get() _conf.add_section('ARGUMENTS') _conf.set('ARGUMENTS', 'DHT_NETWORK_FILTER', str(uuid.uuid4()))
def pytest_configure(config): global _config_pytest _config_pytest = config filename = config.getoption("logfile") if filename: calvinlogger.set_file(filename) levels = config.getoption("loglevel") for level in levels: module = None if ":" in level: module, level = level.split(":") print("Setting debuglevel %s on module %s" % (level, module)) if level == "CRITICAL": calvinlogger.get_logger(module).setLevel(logging.CRITICAL) elif level == "ERROR": calvinlogger.get_logger(module).setLevel(logging.ERROR) elif level == "WARNING": calvinlogger.get_logger(module).setLevel(logging.WARNING) elif level == "INFO": calvinlogger.get_logger(module).setLevel(logging.INFO) elif level == "DEBUG": calvinlogger.get_logger(module).setLevel(logging.DEBUG) elif level == "ANALYZE": calvinlogger.get_logger(module).setLevel(5) if not os.environ.get('CALVIN_GLOBAL_DHT_NETWORK_FILTER'): # TODO: add func to set any argument from here also from calvin.utilities import calvinconfig _conf = calvinconfig.get() _conf.add_section('ARGUMENTS') _conf.set('ARGUMENTS', 'DHT_NETWORK_FILTER', str(uuid.uuid4()))
def test_set_file(create_logger): calvinlogger.set_file("filename") create_logger.assert_called_with("filename")