def get_handlers(self, levels=None): """Return ONAP-compliant log handlers for different levels. Each "level" ends up in a different log file with a prefix of that level. For example: error_log, metrics_log, audit_log, debug_log in that order :param levels: None or list of levels subset of self.default_levels (["error", "metrics", "audit", "debug"]) :return: list of log_handlers in the order of levels requested. if levels is None: we return handlers for self.default_levels if levels is ["error", "audit"], we return log handlers for that. """ create_log_dirs() monkey.patch_all() config.yamlConfig(filepath=LOGGING_FILE, watchDog=False) wanted_levels = self.default_levels if levels is None else levels return [logging.getLogger(x) for x in wanted_levels]
'maxBytes': 1024 * 1024 * 50, 'backupCount': 5, }, }, 'loggers': { 'lcm': { 'handlers': ['lcm_handler'], 'level': 'DEBUG', 'propagate': False }, } } else: LOGGING_CONFIG = None LOGGING_FILE = os.path.join(BASE_DIR, 'lcm/log.yml') config.yamlConfig(filepath=LOGGING_FILE, watchDog=True) if 'test' in sys.argv: from lcm.pub.config import config config.REG_TO_MSB_WHEN_START = False DATABASES = {} DATABASES['default'] = { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': ':memory:', } REST_FRAMEWORK = {} import platform if platform.system() == 'Linux': TEST_RUNNER = 'xmlrunner.extra.djangotestrunner.XMLTestRunner'