From b11bd6cf12fd4e8248c612fbd79e67788b6244c2 Mon Sep 17 00:00:00 2001 From: Brendan Jackman Date: Mon, 23 Oct 2017 17:25:02 +0100 Subject: [PATCH 1/2] utils/log: Whitespace --- wa/utils/log.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wa/utils/log.py b/wa/utils/log.py index 24d82e9c..3c0fa235 100644 --- a/wa/utils/log.py +++ b/wa/utils/log.py @@ -159,9 +159,9 @@ def log_error(e, logger, critical=False): :e: the error to log. should be an instance of ``Exception`` :logger: logger to be used. - :critical: if ``True``, this error will be logged at ``logging.CRITICAL`` + :critical: if ``True``, this error will be logged at ``logging.CRITICAL`` level, otherwise it will be logged as ``logging.ERROR``. - + """ if critical: log_func = logger.critical From 4b7d43de9e6412957b4d37e5aba60433a9bdb969 Mon Sep 17 00:00:00 2001 From: Brendan Jackman Date: Mon, 23 Oct 2017 17:25:15 +0100 Subject: [PATCH 2/2] utils/log: Convert exception to string before passing to Logger Now that we add an event when logging errors, we need to avoid passing an exception object directly to the logger. Otherwise we end up adding the unserializable Exception object to the events list, which causes an error when trying to write the output. --- wa/utils/log.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wa/utils/log.py b/wa/utils/log.py index 3c0fa235..61ebac46 100644 --- a/wa/utils/log.py +++ b/wa/utils/log.py @@ -171,7 +171,7 @@ def log_error(e, logger, critical=False): if isinstance(e, KeyboardInterrupt): log_func('Got CTRL-C. Aborting.') elif isinstance(e, WAError) or isinstance(e, DevlibError): - log_func(e) + log_func(str(e)) elif isinstance(e, subprocess.CalledProcessError): tb = get_traceback() log_func(tb)