Mercurial > libervia-backend
diff src/core/log_config.py @ 1940:3fdacba9da68
core (logs): log color location can now be specified with %(color_start)s and %(color_end)s
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 18 Apr 2016 18:33:59 +0200 |
parents | 2daf7b4c6756 |
children | befdcfc55569 |
line wrap: on
line diff
--- a/src/core/log_config.py Mon Apr 18 18:33:55 2016 +0200 +++ b/src/core/log_config.py Mon Apr 18 18:33:59 2016 +0200 @@ -258,6 +258,7 @@ self.level = level def configureFormat(self, fmt): + super(ConfigureStandard, self).configureFormat(fmt) import logging class SatFormatter(logging.Formatter): @@ -272,8 +273,17 @@ def format(self, record): if self._with_profile: record.profile = ConfigureStandard.getProfile() + do_color = self.with_colors and (self.can_colors or self.force_colors) + if ConfigureStandard._color_location: + # we copy raw formatting strings for color_* + # as formatting is handled in ansiColors in this case + if do_color: + record.color_start = log.COLOR_START + record.color_end = log.COLOR_END + else: + record.color_start = record.color_end = '' s = super(SatFormatter, self).format(record) - if self.with_colors and (self.can_colors or self.force_colors): + if do_color: s = ConfigureStandard.ansiColors(record.levelname, s) return s