From e66a04ddf06564b156b0619eb9279da9f626771a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= Date: Fri, 12 Jun 2015 15:27:26 +0200 Subject: [PATCH] utils.stacktrace: Add log_message function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: Lukáš Doktor --- avocado/utils/stacktrace.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/avocado/utils/stacktrace.py b/avocado/utils/stacktrace.py index e4f29846..2ffb2270 100644 --- a/avocado/utils/stacktrace.py +++ b/avocado/utils/stacktrace.py @@ -41,3 +41,15 @@ def log_exc_info(exc_info, logger='root'): for l in line.splitlines(): log.error(l) 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) -- GitLab