]> Frank Brehm's Git Trees - pixelpark/puppetmaster-webhooks.git/commitdiff
Changing init logging
authorFrank Brehm <frank.brehm@pixelpark.com>
Mon, 7 Jan 2019 15:00:03 +0000 (16:00 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Mon, 7 Jan 2019 15:00:03 +0000 (16:00 +0100)
lib/webhooks/base_app.py

index 48b172685b05c09ea164fd50dbe00653666a90e7..bd3cf5df7e1f26178211345bb931a59964d634b9 100644 (file)
@@ -35,6 +35,7 @@ import pytz
 
 # Own modules
 from fb_tools.common import pp, to_bytes, to_bool
+from fb_tools.colored import ColoredFormatter
 from fb_tools.handler import BaseHandler
 from fb_tools.errors import FbAppError, FunctionNotImplementedError
 from fb_tools.app import BaseApplication
@@ -743,7 +744,10 @@ class BaseHookApp(BaseApplication):
             else:
                 format_str += '%(name)s '
         format_str += '%(levelname)s - %(message)s'
-        formatter = logging.Formatter(format_str)
+        if not self.is_cgi and self.terminal_has_colors:
+            formatter = ColoredFormatter(format_str)
+        else:
+            formatter = logging.Formatter(format_str)
 
         return formatter