From 280225059605d280bef104dc552ad165b188541b Mon Sep 17 00:00:00 2001 From: Goffi Date: Mon, 5 May 2014 20:16:13 +0200 Subject: [PATCH] core (log/standard backend): added "%(profile)s" format management --- src/core/log.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/core/log.py b/src/core/log.py index e9f7c007..3ab185b2 100644 --- a/src/core/log.py +++ b/src/core/log.py @@ -189,6 +189,8 @@ def _getProfile(): 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 @@ def _getProfile(): 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 ConfigureStandard(Configure): 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)