summaryrefslogtreecommitdiffstats
path: root/ipapython
diff options
context:
space:
mode:
authorJohn Dennis <jdennis@redhat.com>2011-11-30 11:08:42 -0500
committerMartin Kosek <mkosek@redhat.com>2011-12-01 08:34:02 +0100
commit167813f34350466be569be26f4faa8b9a05e5920 (patch)
treee9df21a77042214ff5416c6e475d61378185e296 /ipapython
parent27931dcb29ebeb15aae4d17d745252ba75f69bae (diff)
downloadfreeipa-167813f34350466be569be26f4faa8b9a05e5920.tar.gz
freeipa-167813f34350466be569be26f4faa8b9a05e5920.tar.xz
freeipa-167813f34350466be569be26f4faa8b9a05e5920.zip
Restore default log level in server to INFO
The default log level for server messages captured by httpd's error_log historically was INFO. The log_manager patch had it set to ERROR, this patch resets it back to INFO. Although it would have been trival to set the default_level to INFO in IPALogManager.configure_from_env() that is not logically the correct place. It would be much better if the default_level can be reset by simply assigning it to the log_mgr. To accomplish that LogManager.default_level was converted to a property with a getter and setter. The setter runs LogManager.apply_configuratin() after the default_level is modified. LogManager.set_default_level() was also added to allow simultaneously updating the configure_state. While testing some minor problems were observed and also fixed: * Removed some print statement which had been left in by mistake * Removed the ability to set the handler level in the config file because of chicken-and-egg issues of when handlers get created. The Env config file format is too inflexible to support detailed logging configuration. If the Env config format is ever made more flexible we can come back and add this back in. The handler config setting in Env had never been used and never worked so there is no issue in removing it.
Diffstat (limited to 'ipapython')
-rw-r--r--ipapython/ipa_log_manager.py47
-rw-r--r--ipapython/log_manager.py43
2 files changed, 39 insertions, 51 deletions
diff --git a/ipapython/ipa_log_manager.py b/ipapython/ipa_log_manager.py
index 11e30d11a..7841eabfb 100644
--- a/ipapython/ipa_log_manager.py
+++ b/ipapython/ipa_log_manager.py
@@ -75,7 +75,6 @@ class IPALogManager(LogManager):
'''
log_logger_level_config_re = re.compile(r'^log_logger_level_(debug|info|warn|warning|error|critical|\d+)$')
- log_handler_level_config_re = re.compile(r'^log_handler_(\S+)_level$')
def __init__(self, configure_state=None):
'''
@@ -117,37 +116,11 @@ class IPALogManager(LogManager):
will usually need to escape the dot in the logger names by
preceeding it with a backslash.
- Handler Levels
- *log_handler_XXX_level = level*
-
- Handler levels may be specified with a key containing the
- name of the handler (XXX) and whose value is the level. For
- example::
-
- log_handler_console_level = debug
-
- Would set the console handler level to debug.
-
- These are the predefined log handlers:
-
- console
- Writes to stderr.
- file
- Writes to the default log file.
-
-
The return value of this function is a dict with the following
format:
logger_regexps
List of (regexp, level) tuples
- handlers
- Dict, key is handler name, value is dict of handler config.
-
- Handler config dict:
-
- level
- handler log level
:parameters:
env
@@ -158,9 +131,7 @@ class IPALogManager(LogManager):
use configure_state to track the state of the log manager.
'''
logger_regexps = []
- handlers = {}
config = {'logger_regexps' : logger_regexps,
- 'handlers' : handlers,
}
for attr in ('debug', 'verbose'):
@@ -178,27 +149,9 @@ class IPALogManager(LogManager):
regexps = re.split('\s*,\s*', value)
# Add the regexp, it maps to the configured level
for regexp in regexps:
- print "%s %s" % (regexp, level)
logger_regexps.append((regexp, level))
continue
- # Get handler configuration
- match = IPALogManager.log_handler_level_config_re.search(attr)
- if match:
- value = getattr(env, attr)
- try:
- level = parse_log_level(value)
- except Exception, e:
- print >>sys.stderr, 'ERROR could not parse log handler level: %s=%s' % (attr, value)
- continue
- name = match.group(1)
- print "%s %s" % (name, level)
- handler_config = handlers.get(name)
- if handler_config is None:
- handler_config = {'name' : name}
- handler_config['level'] = level
- continue
-
self.configure(config, configure_state)
return config
diff --git a/ipapython/log_manager.py b/ipapython/log_manager.py
index 736d95310..c84714210 100644
--- a/ipapython/log_manager.py
+++ b/ipapython/log_manager.py
@@ -769,21 +769,56 @@ class LogManager(object):
LogManager instance
'''
+ self.loggers = {} # dict, key is logger name, value is logger object
+ self.handlers = {} # dict, key is handler name, value is handler object
+
self.configure_state = configure_state
self.root_logger_name = root_logger_name
- self.default_level = logging.ERROR
+ self.default_level = 'error'
self.debug = False
self.verbose = False
self.logger_regexps = []
- self.loggers = {} # dict, key is logger name, value is logger object
- self.handlers = {} # dict, key is handler name, value is handler object
-
self.root_logger = self.get_logger(self.root_logger_name)
# Stop loggers and handlers from searching above our root
self.root_logger.propagate = False
+ def _get_default_level(self):
+ return self._default_level
+
+ def _set_default_level(self, value):
+ level = parse_log_level(value)
+ self._default_level = level
+ self.apply_configuration()
+
+ default_level = property(_get_default_level, _set_default_level,
+ doc='see log_manager.parse_log_level()` for details on how the level can be specified during assignement.')
+
+ def set_default_level(self, level, configure_state=None):
+ '''
+ Reset the default logger level, updates all loggers.
+ Note, the default_level may also be set by assigning to the
+ default_level attribute but that does not update the configure_state,
+ this method is provided as a convenience to simultaneously set the
+ configure_state if so desired.
+
+ :parameters:
+ level
+ The new default level for the log manager. See
+ `log_manager.parse_log_level()` for details on how the
+ level can be specified.
+ configure_state
+ If other than None update the log manger's configure_state
+ variable to this object. Clients of the log manager can
+ use configure_state to track the state of the log manager.
+
+ '''
+ level = parse_log_level(level)
+ self._default_level = level
+ self.apply_configuration(configure_state)
+
+
def __str__(self):
'''
When str() is called on the LogManager output it's state.