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:
Goffi 2016-04-18 18:35:17 +02:00
commit 1e05785e83

View file

@ -194,6 +194,12 @@ class Const(object):
## Logging ##
LOG_LVL_DEBUG = 'DEBUG'
LOG_LVL_INFO = 'INFO'
LOG_LVL_WARNING = 'WARNING'
LOG_LVL_ERROR = 'ERROR'
LOG_LVL_CRITICAL = 'CRITICAL'
LOG_LEVELS = (LOG_LVL_DEBUG, LOG_LVL_INFO, LOG_LVL_WARNING, LOG_LVL_ERROR, LOG_LVL_CRITICAL)
LOG_BACKEND_STANDARD = 'standard'
LOG_BACKEND_TWISTED = 'twisted'
LOG_BACKEND_BASIC = 'basic'
@ -204,6 +210,13 @@ class Const(object):
LOG_OPT_PREFIX = 'log_'
# (option_name, default_value) tuples
LOG_OPT_COLORS = ('colors', 'true') # true for auto colors, force to have colors even if stdout is not a tty, false for no color
LOG_OPT_TAINTS_DICT = ('levels_taints_dict', {
LOG_LVL_DEBUG: ('cyan',),
LOG_LVL_INFO: (),
LOG_LVL_WARNING: ('yellow',),
LOG_LVL_ERROR: ('red', 'blink', r'/!\ ', 'blink_off'),
LOG_LVL_CRITICAL: ('bold', 'red', 'Guru Meditation ', 'normal_weight')
})
LOG_OPT_LEVEL = ('level', 'info')
LOG_OPT_FORMAT = ('fmt', '%(message)s') # similar to logging format.
LOG_OPT_LOGGER = ('logger', '') # regex to filter logger name
@ -213,12 +226,6 @@ class Const(object):
LOG_OPT_OUTPUT_MEMORY_LIMIT = 50
LOG_OPT_OUTPUT_FILE = 'file' # file is implicit if only output
LOG_OPT_OUTPUT = ('output', LOG_OPT_OUTPUT_SEP + LOG_OPT_OUTPUT_DEFAULT) # //default = normal output (stderr or a file with twistd), path/to/file for a file (must be the first if used), //memory for memory (options can be put in parenthesis, e.g.: //memory(500) for a 500 lines memory)
LOG_LVL_DEBUG = 'DEBUG'
LOG_LVL_INFO = 'INFO'
LOG_LVL_WARNING = 'WARNING'
LOG_LVL_ERROR = 'ERROR'
LOG_LVL_CRITICAL = 'CRITICAL'
LOG_LEVELS = (LOG_LVL_DEBUG, LOG_LVL_INFO, LOG_LVL_WARNING, LOG_LVL_ERROR, LOG_LVL_CRITICAL)
## action constants ##
@ -263,7 +270,7 @@ class Const(object):
def LOG_OPTIONS(cls):
"""Return options checked for logs"""
# XXX: we use a classmethod so we can use Const inheritance to change default options
return(cls.LOG_OPT_COLORS, cls.LOG_OPT_LEVEL, cls.LOG_OPT_FORMAT, cls.LOG_OPT_LOGGER, cls.LOG_OPT_OUTPUT)
return(cls.LOG_OPT_COLORS, cls.LOG_OPT_TAINTS_DICT, cls.LOG_OPT_LEVEL, cls.LOG_OPT_FORMAT, cls.LOG_OPT_LOGGER, cls.LOG_OPT_OUTPUT)
@classmethod
def bool(cls, value):