Mercurial > libervia-backend
diff src/core/constants.py @ 1942:7f053e1f0b67
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.
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 18 Apr 2016 18:35:17 +0200 |
parents | 2daf7b4c6756 |
children | ca5a883f8abe |
line wrap: on
line diff
--- a/src/core/constants.py Mon Apr 18 18:33:59 2016 +0200 +++ b/src/core/constants.py Mon Apr 18 18:35:17 2016 +0200 @@ -194,6 +194,12 @@ ## 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 @@ 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 @@ 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 @@ 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):