我已在WARN
和platform_settings.py
文件中将日志级别设置为loggings.py
。
我还使用WARN
将forms.py
中的初始值更改为(self.fields['log_level'].initial='WARN')
。
现在,如果我将值从WARN
更改为INFO
或CRITICAL
,我希望它在UI中反映,而不是每次都设置[log_level.initial]
。我将如何进行更改?
platform_settings.py
for l in loggers:
logger = logging.getLogger(l)
logger.setLevel(level)
logging.py
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'cloudos_format': {
'format': '%(filename)s [(process)d-%(thread)d-%(clientip)s]%(module)s.%(funcName)s:%(message)s'
},
},
'handlers': {
'null': {
'level': 'WARN',
'class': 'django.utils.log.NullHandler',
},
forms.py
choices = [ ('WARN', 'Warning'),
('ERROR', 'Error'),
('CRITICAL', 'Critical'),
('INFO', 'Info'),
('DEBUG', 'Debug') ]
self.fields['log_level'].choices = choices
# self.fields['log_level'].initial='WARN'
cache_val = cloudos_cache.get('all_users', 'log_level')
if cache_val:
self.fields['log_level'].initial = cache_val
else:
logger = logging.getLogger('skyline')
Lev=logging.getLevelName(level)
logger.setLevel(Lev)