From b97fe09ed9784ac55df53101ef522cece1053aac Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sun, 25 Feb 2018 10:38:52 +0200 Subject: [PATCH] logging: Add exc() and exception() methods. Non-standard exc() method accepts exception instance to log as a parameter. exception() just uses sys.exc_info(). --- logging/logging.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/logging/logging.py b/logging/logging.py index 0e1b7f04..cea2de03 100644 --- a/logging/logging.py +++ b/logging/logging.py @@ -59,6 +59,13 @@ class Logger: def critical(self, msg, *args): self.log(CRITICAL, msg, *args) + def exc(self, e, msg, *args): + self.log(ERROR, msg, *args) + sys.print_exception(e, _stream) + + def exception(self, msg, *args): + self.exc(sys.exc_info()[1], msg, *args) + _level = INFO _loggers = {}