Edgewall Software

Opened 7 years ago

Last modified 7 years ago

#12779 closed defect

[logging] log_level option is case-sensitive after Trac 1.2 — at Version 1

Reported by: Jun Omae Owned by: Ryan J Ollos
Priority: normal Milestone: 1.2.2
Component: general Version: 1.2
Severity: minor Keywords:
Cc: Branch:
Release Notes:

Fixed [logging] log_level was incorrect case-sensitive after Trac 1.1.3.

API Changes:
Internal Changes:

Description

$ ~/venv/trac/1.0.13/trac-admin /dev/shm/tracenv-1.0
Welcome to trac-admin 1.0.13
Interactive Trac administration console.
Copyright (C) 2003-2013 Edgewall Software

Type:  '?' or 'help' for help on commands.

Trac [/dev/shm/tracenv-1.0]> config get logging log_level
info
Trac [/dev/shm/tracenv-1.0]>
$ ~/venv/trac/1.2/trac-admin /dev/shm/tracenv-1.0
Welcome to trac-admin 1.2
Interactive Trac administration console.
Copyright (C) 2003-2013 Edgewall Software

Type:  '?' or 'help' for help on commands.

Trac [/dev/shm/tracenv-1.0]> upgrade
Error: [logging] log_level: expected one of ("ALL", "CRITICAL", "DEBUG", "ERROR", "INFO", "WARN", "WARNING"), got u'info'

Change History (1)

comment:1 by Ryan J Ollos, 7 years ago

Owner: set to Ryan J Ollos
Release Notes: modified (diff)
Status: newassigned

Regression from #11573. We could add a case_sensitive argument to ChoiceOption.

  • trac/config.py

    diff --git a/trac/config.py b/trac/config.py
    index cd43e8887..b8ad92e0e 100644
    a b class ChoiceOption(Option):  
    819819    """
    820820
    821821    def __init__(self, section, name, choices, doc='', doc_domain='tracini',
    822                  doc_args=None):
     822                 doc_args=None, case_sensitive=True):
    823823        Option.__init__(self, section, name, to_unicode(choices[0]), doc,
    824824                        doc_domain, doc_args)
    825825        self.choices = set(to_unicode(c).strip() for c in choices)
     826        self.case_sensitive = case_sensitive
    826827
    827828    def accessor(self, section, name, default):
    828829        value = section.get(name, default)
    829         if value not in self.choices:
     830        choices = self.choices
     831        if not self.case_sensitive:
     832            value = value.lower()
     833            choices = map(unicode.lower, choices)
     834        if value not in choices:
    830835            raise ConfigurationError(
    831836                    _('[%(section)s] %(entry)s: expected one of '
    832837                      '(%(choices)s), got %(value)s',
  • trac/env.py

    diff --git a/trac/env.py b/trac/env.py
    index 0ecbb5b42..19c2b5f3d 100644
    a b class Environment(Component, ComponentManager):  
    250250        """Level of verbosity in log.
    251251
    252252        Should be one of (`CRITICAL`, `ERROR`, `WARNING`, `INFO`, `DEBUG`).
    253         """)
     253        """, case_sensitive=False)
    254254
    255255    log_format = Option('logging', 'log_format', None,
    256256        """Custom logging format.

I would prefer to not make case_sensitive be the last argument in the list, but I suppose that is required for backward-compatibility.

Note: See TracTickets for help on using tickets.