1

我已将日志级别设置为WARNplatform_settings.py文件loggings.py

我还将初始值更改为WARNin forms.pywith (self.fields['log_level'].initial='WARN')

现在,如果我将值从 更改WARNINFOCRITICAL,我希望它反映在 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)
4

0 回答 0