changeset 1013:11409a6c16c7

core (log/standard backend): added "%(profile)s" format management
author Goffi <goffi@goffi.org>
date Mon, 05 May 2014 20:16:13 +0200
parents c8771279497e
children e40d9858cb83
files src/core/log.py
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/core/log.py	Mon May 05 20:16:08 2014 +0200
+++ b/src/core/log.py	Mon May 05 20:16:13 2014 +0200
@@ -189,6 +189,8 @@
     current_path = stack[0][1]
     for frame_data in stack[:-1]:
         if frame_data[1] != current_path:
+            if _backend == C.LOG_BACKEND_STANDARD and "/logging/__init__.py" in frame_data[1]:
+                continue
             break
 
     frame = frame_data[0]
@@ -200,7 +202,10 @@
             try:
                 profile = args.locals['self'].profile
             except AttributeError:
-                profile = args.locals['self'].parent.profile
+                try:
+                    profile = args.locals['self'].parent.profile
+                except AttributeError:
+                    profile = args.locals['self'].host.profile # used in quick_frontend for single profile configuration
         except Exception:
             # we can't find profile, we return an empty value
             profile = ''
@@ -555,12 +560,15 @@
         class SatFormatter(logging.Formatter):
             u"""Formatter which manage SàT specificities"""
             _format = fmt
+            _with_profile = '%(profile)s' in fmt
 
             def __init__(self, can_colors=False):
                 super(SatFormatter, self).__init__(self._format)
                 self.can_colors = can_colors
 
             def format(self, record):
+                if self._with_profile:
+                    record.profile = _getProfile()
                 s = super(SatFormatter, self).format(record)
                 if self.with_colors and (self.can_colors or self.force_colors):
                     s = _ansiColors(record.levelname, s)