comparison 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
comparison
equal deleted inserted replaced
1941:befdcfc55569 1942:7f053e1f0b67
192 XMLUI_DATA_FILETYPE_DIR = "dir" 192 XMLUI_DATA_FILETYPE_DIR = "dir"
193 XMLUI_DATA_FILETYPE_DEFAULT = XMLUI_DATA_FILETYPE_FILE 193 XMLUI_DATA_FILETYPE_DEFAULT = XMLUI_DATA_FILETYPE_FILE
194 194
195 195
196 ## Logging ## 196 ## Logging ##
197 LOG_LVL_DEBUG = 'DEBUG'
198 LOG_LVL_INFO = 'INFO'
199 LOG_LVL_WARNING = 'WARNING'
200 LOG_LVL_ERROR = 'ERROR'
201 LOG_LVL_CRITICAL = 'CRITICAL'
202 LOG_LEVELS = (LOG_LVL_DEBUG, LOG_LVL_INFO, LOG_LVL_WARNING, LOG_LVL_ERROR, LOG_LVL_CRITICAL)
197 LOG_BACKEND_STANDARD = 'standard' 203 LOG_BACKEND_STANDARD = 'standard'
198 LOG_BACKEND_TWISTED = 'twisted' 204 LOG_BACKEND_TWISTED = 'twisted'
199 LOG_BACKEND_BASIC = 'basic' 205 LOG_BACKEND_BASIC = 'basic'
200 LOG_BACKEND_CUSTOM = 'custom' 206 LOG_BACKEND_CUSTOM = 'custom'
201 LOG_BASE_LOGGER = 'root' 207 LOG_BASE_LOGGER = 'root'
202 LOG_TWISTED_LOGGER = 'twisted' 208 LOG_TWISTED_LOGGER = 'twisted'
203 LOG_OPT_SECTION = 'DEFAULT' # section of sat.conf where log options should be 209 LOG_OPT_SECTION = 'DEFAULT' # section of sat.conf where log options should be
204 LOG_OPT_PREFIX = 'log_' 210 LOG_OPT_PREFIX = 'log_'
205 # (option_name, default_value) tuples 211 # (option_name, default_value) tuples
206 LOG_OPT_COLORS = ('colors', 'true') # true for auto colors, force to have colors even if stdout is not a tty, false for no color 212 LOG_OPT_COLORS = ('colors', 'true') # true for auto colors, force to have colors even if stdout is not a tty, false for no color
213 LOG_OPT_TAINTS_DICT = ('levels_taints_dict', {
214 LOG_LVL_DEBUG: ('cyan',),
215 LOG_LVL_INFO: (),
216 LOG_LVL_WARNING: ('yellow',),
217 LOG_LVL_ERROR: ('red', 'blink', r'/!\ ', 'blink_off'),
218 LOG_LVL_CRITICAL: ('bold', 'red', 'Guru Meditation ', 'normal_weight')
219 })
207 LOG_OPT_LEVEL = ('level', 'info') 220 LOG_OPT_LEVEL = ('level', 'info')
208 LOG_OPT_FORMAT = ('fmt', '%(message)s') # similar to logging format. 221 LOG_OPT_FORMAT = ('fmt', '%(message)s') # similar to logging format.
209 LOG_OPT_LOGGER = ('logger', '') # regex to filter logger name 222 LOG_OPT_LOGGER = ('logger', '') # regex to filter logger name
210 LOG_OPT_OUTPUT_SEP = '//' 223 LOG_OPT_OUTPUT_SEP = '//'
211 LOG_OPT_OUTPUT_DEFAULT = 'default' 224 LOG_OPT_OUTPUT_DEFAULT = 'default'
212 LOG_OPT_OUTPUT_MEMORY = 'memory' 225 LOG_OPT_OUTPUT_MEMORY = 'memory'
213 LOG_OPT_OUTPUT_MEMORY_LIMIT = 50 226 LOG_OPT_OUTPUT_MEMORY_LIMIT = 50
214 LOG_OPT_OUTPUT_FILE = 'file' # file is implicit if only output 227 LOG_OPT_OUTPUT_FILE = 'file' # file is implicit if only output
215 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) 228 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)
216 LOG_LVL_DEBUG = 'DEBUG'
217 LOG_LVL_INFO = 'INFO'
218 LOG_LVL_WARNING = 'WARNING'
219 LOG_LVL_ERROR = 'ERROR'
220 LOG_LVL_CRITICAL = 'CRITICAL'
221 LOG_LEVELS = (LOG_LVL_DEBUG, LOG_LVL_INFO, LOG_LVL_WARNING, LOG_LVL_ERROR, LOG_LVL_CRITICAL)
222 229
223 230
224 ## action constants ## 231 ## action constants ##
225 META_TYPE_FILE = "file" 232 META_TYPE_FILE = "file"
226 META_TYPE_OVERWRITE = "overwrite" 233 META_TYPE_OVERWRITE = "overwrite"
261 268
262 @classmethod 269 @classmethod
263 def LOG_OPTIONS(cls): 270 def LOG_OPTIONS(cls):
264 """Return options checked for logs""" 271 """Return options checked for logs"""
265 # XXX: we use a classmethod so we can use Const inheritance to change default options 272 # XXX: we use a classmethod so we can use Const inheritance to change default options
266 return(cls.LOG_OPT_COLORS, cls.LOG_OPT_LEVEL, cls.LOG_OPT_FORMAT, cls.LOG_OPT_LOGGER, cls.LOG_OPT_OUTPUT) 273 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)
267 274
268 @classmethod 275 @classmethod
269 def bool(cls, value): 276 def bool(cls, value):
270 """@return (bool): bool value for associated constant""" 277 """@return (bool): bool value for associated constant"""
271 assert isinstance(value, basestring) 278 assert isinstance(value, basestring)