comparison src/core/constants.py @ 994:652c01ca69b1

core (log): configuration and environment variables are now checked for log level and colors: - variable change logs behaviour, so far only level and colors are implemented - configuration use log_[name], for example you can put log_level=debug in sat.conf (section [DEFAULT]) to see all levels - environment variables use SAT_LOG_[NAME]: e.g. SAT_LOG_LEVEL=debug - colors can be true, false or force to force colors even if stdout is not a tty
author Goffi <goffi@goffi.org>
date Sat, 19 Apr 2014 20:11:23 +0200
parents 05e02f8b7eb4
children eb3601ff73bc
comparison
equal deleted inserted replaced
993:301b342c697a 994:652c01ca69b1
32 APP_NAME_SHORT = u'SàT' 32 APP_NAME_SHORT = u'SàT'
33 APP_NAME_FULL = u'%s (%s)' % (APP_NAME_SHORT, APP_NAME) 33 APP_NAME_FULL = u'%s (%s)' % (APP_NAME_SHORT, APP_NAME)
34 APP_VERSION = u'0.4.1D' # Please add 'D' at the end for dev versions 34 APP_VERSION = u'0.4.1D' # Please add 'D' at the end for dev versions
35 APP_URL = 'http://salut-a-toi.org' 35 APP_URL = 'http://salut-a-toi.org'
36 36
37
37 ## Parameters ## 38 ## Parameters ##
38 NO_SECURITY_LIMIT = -1 39 NO_SECURITY_LIMIT = -1
39 INDIVIDUAL = "individual" 40 INDIVIDUAL = "individual"
40 GENERAL = "general" 41 GENERAL = "general"
41 42
45 PROF_KEY_DEFAULT = '@DEFAULT@' 46 PROF_KEY_DEFAULT = '@DEFAULT@'
46 ENTITY_ALL = '@ALL@' 47 ENTITY_ALL = '@ALL@'
47 ENTITY_LAST_RESOURCE = 'LAST_RESOURCE' 48 ENTITY_LAST_RESOURCE = 'LAST_RESOURCE'
48 ENTITY_CAP_HASH = 'CAP_HASH' 49 ENTITY_CAP_HASH = 'CAP_HASH'
49 50
51
52 ## Configuration ##
50 if BaseDirectory: # skipped when imported from Libervia browser_side 53 if BaseDirectory: # skipped when imported from Libervia browser_side
51 54
52 ## Configuration ## 55 ## Configuration ##
53 DEFAULT_CONFIG = { 56 DEFAULT_CONFIG = {
54 'media_dir': '/usr/share/sat/media', 57 'media_dir': '/usr/share/sat/media',
64 67
65 # List of the configuration filenames sorted by ascending priority 68 # List of the configuration filenames sorted by ascending priority
66 CONFIG_FILES = [(os.path.expanduser(path) + 'sat.conf') for path in \ 69 CONFIG_FILES = [(os.path.expanduser(path) + 'sat.conf') for path in \
67 ['/etc/', '~/', '~/.', '', '.'] + \ 70 ['/etc/', '~/', '~/.', '', '.'] + \
68 ['%s/' % path for path in list(BaseDirectory.load_config_paths('sat'))] 71 ['%s/' % path for path in list(BaseDirectory.load_config_paths('sat'))]
69 ] 72 ]
73
70 74
71 ## Plugins ## 75 ## Plugins ##
72 # names of widely used plugins 76 # names of widely used plugins
73 TEXT_CMDS = 'TEXT-COMMANDS' 77 TEXT_CMDS = 'TEXT-COMMANDS'
78
74 79
75 ## Logging ## 80 ## Logging ##
76 LOG_BACKEND_STANDARD = 'standard' 81 LOG_BACKEND_STANDARD = 'standard'
77 LOG_BACKEND_TWISTED = 'twisted' 82 LOG_BACKEND_TWISTED = 'twisted'
78 LOG_BACKEND_BASIC = 'basic' 83 LOG_BACKEND_BASIC = 'basic'
79 LOG_BASE_LOGGER = 'root' 84 LOG_BASE_LOGGER = 'root'
85 LOG_OPT_PREFIX = 'log_'
86 # (option_name, default_value) tuples
87 LOG_OPT_COLORS = ('colors', 'true')
88 LOG_OPT_LEVEL = ('level', 'info')
89
80 90
81 ## Misc ## 91 ## Misc ##
82 SAVEFILE_DATABASE = "sat.db" 92 SAVEFILE_DATABASE = "sat.db"
83 IQ_SET = '/iq[@type="set"]' 93 IQ_SET = '/iq[@type="set"]'
94 ENV_PREFIX = 'SAT_' # Prefix used for environment variables
95
84 96
85 ## ANSI escape sequences ## 97 ## ANSI escape sequences ##
86 # XXX: used for logging 98 # XXX: used for logging
87 # XXX: there will be probably moved in a dedicated module in the future 99 # XXX: there will be probably moved in a dedicated module in the future
88 ANSI_RESET = '\033[0m' 100 ANSI_RESET = '\033[0m'