本文整理汇总了Python中celery.utils.log.get_logger方法的典型用法代码示例。如果您正苦于以下问题:Python log.get_logger方法的具体用法?Python log.get_logger怎么用?Python log.get_logger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类celery.utils.log
的用法示例。
在下文中一共展示了log.get_logger方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: reset_loggers_level
# 需要导入模块: from celery.utils import log [as 别名]
# 或者: from celery.utils.log import get_logger [as 别名]
def reset_loggers_level():
"""
Reset loggers' level from AppVar
"""
def getEffectiveLevel(self):
"""
Get the effective level for this logger.
Loop through this logger and its parents in the logger hierarchy,
looking for a non-zero logging level. Return the first one found.
"""
logger = self
# custom logic
# cannot use AppVar due to circular import issue
app_var_level = redis.pop(f'app_var:Logging:logger:{logger.name}:log_level')
if app_var_level:
app_var_level = app_var_level.upper()
if app_var_level in logging._levelToName.values():
logger.setLevel(app_var_level)
# log sql to console
if logger.name == 'django.db.backends':
handler = logging.StreamHandler()
handler.setLevel(logger.level)
logger_handler_classes = [i.__class__ for i in logger.handlers]
if redis.pop(f'app_var:Logging:logger:{logger.name}:log_to_console') is True:
if handler.__class__ not in logger_handler_classes:
logger.addHandler(handler)
else:
logger.handlers = [i for i in logger.handlers if i.__class__ != handler.__class__]
# end custom logic
while logger:
if logger.level:
return logger.level
logger = logger.parent
return logging.NOTSET
# reset Project loggers
for logger_name in settings.LOGGING['loggers']:
logger = logging.getLogger(logger_name)
logger.getEffectiveLevel = types.MethodType(getEffectiveLevel, logger)
# reset celery loggers
for logger_name in celery_logger_names:
logger = get_logger(logger_name)
logger.getEffectiveLevel = types.MethodType(getEffectiveLevel, logger)