提交 e66a04dd 编写于 作者: L Lukáš Doktor

utils.stacktrace: Add log_message function

This function is a wrapper around logging.getLogger and it uses the
same format as log_exc_info. It's useful for logging exception details
and other explanation to specific logger.
Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>
上级 d1d213f7
...@@ -41,3 +41,15 @@ def log_exc_info(exc_info, logger='root'): ...@@ -41,3 +41,15 @@ def log_exc_info(exc_info, logger='root'):
for l in line.splitlines(): for l in line.splitlines():
log.error(l) log.error(l)
log.error('') log.error('')
def log_message(message, logger='root'):
"""
Log message to logger.
:param message: Message
:param logger: Name of the logger (defaults to root)
"""
log = logging.getLogger(logger)
for line in message.splitlines():
log.error(line)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册