# HG changeset patch # User Goffi # Date 1399313773 -7200 # Node ID 11409a6c16c7ef0dbd7e4a50d5c40eeca136da27 # Parent c8771279497edb962e40c5ea7a24a1bf35d8726d core (log/standard backend): added "%(profile)s" format management diff -r c8771279497e -r 11409a6c16c7 src/core/log.py --- 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)