core (logs): taints:
log taints can be specified using log_levels_taints_dict in sat.conf, where key is a level name, and value is a list of color or code names. For instance, the following conf would taint INFO level in bold/green and DEBUG in default color:
log_levels_taints_dict = {"debug": [], "info": ["green", "bold"]}
Unknown names are copied as raw strings.
This commit is contained in:
parent
864520086a
commit
1e05785e83
1 changed files with 56 additions and 37 deletions
|
|
@ -43,12 +43,13 @@ class TwistedLogger(log.Logger):
|
|||
|
||||
class ConfigureBasic(log.ConfigureBase):
|
||||
|
||||
def configureColors(self, colors, force_colors):
|
||||
def configureColors(self, colors, force_colors, levels_taints_dict):
|
||||
super(ConfigureBasic, self).configureColors(colors, force_colors, levels_taints_dict)
|
||||
if colors:
|
||||
import sys
|
||||
if force_colors or sys.stdout.isatty(): # FIXME: isatty should be tested on each handler, not globaly
|
||||
# we need colors
|
||||
log.Logger.post_treat = lambda self, level, message: self.ansiColors(level, message)
|
||||
log.Logger.post_treat = lambda logger, level, message: self.ansiColors(level, message)
|
||||
elif force_colors:
|
||||
raise ValueError("force_colors can't be used if colors is False")
|
||||
|
||||
|
|
@ -210,7 +211,8 @@ class ConfigureTwisted(ConfigureBasic):
|
|||
if C.LOG_OPT_OUTPUT_MEMORY in log.handlers:
|
||||
raise NotImplementedError("Memory observer is not implemented in Twisted backend")
|
||||
|
||||
def configureColors(self, colors, force_colors):
|
||||
def configureColors(self, colors, force_colors, levels_taints_dict):
|
||||
super(ConfigureTwisted, self).configureColors(colors, force_colors, levels_taints_dict)
|
||||
self.LOGGER_CLASS.colors = colors
|
||||
self.LOGGER_CLASS.force_colors = force_colors
|
||||
if force_colors and not colors:
|
||||
|
|
@ -235,12 +237,12 @@ class ConfigureTwisted(ConfigureBasic):
|
|||
|
||||
class ConfigureStandard(ConfigureBasic):
|
||||
|
||||
def __init__(self, level=None, fmt=None, output=None, logger=None, colors=False, force_colors=False, backend_data=None):
|
||||
def __init__(self, level=None, fmt=None, output=None, logger=None, colors=False, levels_taints_dict=None, force_colors=False, backend_data=None):
|
||||
if fmt is None:
|
||||
fmt = C.LOG_OPT_FORMAT[1]
|
||||
if output is None:
|
||||
output = C.LOG_OPT_OUTPUT[1]
|
||||
super(ConfigureStandard, self).__init__(level, fmt, output, logger, colors, force_colors, backend_data)
|
||||
super(ConfigureStandard, self).__init__(level, fmt, output, logger, colors, levels_taints_dict, force_colors, backend_data)
|
||||
|
||||
def preTreatment(self):
|
||||
"""We use logging methods directly, instead of using Logger"""
|
||||
|
|
@ -295,7 +297,8 @@ class ConfigureStandard(ConfigureBasic):
|
|||
def configureLogger(self, logger):
|
||||
self.name_filter = log.FilterName(logger) if logger else None
|
||||
|
||||
def configureColors(self, colors, force_colors):
|
||||
def configureColors(self, colors, force_colors, levels_taints_dict):
|
||||
super(ConfigureStandard, self).configureColors(colors, force_colors, levels_taints_dict)
|
||||
self.formatterClass.with_colors = colors
|
||||
self.formatterClass.force_colors = force_colors
|
||||
if not colors and force_colors:
|
||||
|
|
|
|||
Loading…
Reference in a new issue