core (logs): log color location can now be specified with %(color_start)s and %(color_end)s
This commit is contained in:
parent
e8783b42df
commit
304b1eb34b
1 changed files with 40 additions and 19 deletions
|
|
@ -258,6 +258,7 @@ class ConfigureStandard(ConfigureBasic):
|
|||
self.level = level
|
||||
|
||||
def configureFormat(self, fmt):
|
||||
super(ConfigureStandard, self).configureFormat(fmt)
|
||||
import logging
|
||||
|
||||
class SatFormatter(logging.Formatter):
|
||||
|
|
@ -272,8 +273,17 @@ class ConfigureStandard(ConfigureBasic):
|
|||
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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue