diff options
author | Michal Minar <miminar@redhat.com> | 2013-08-27 11:22:38 +0200 |
---|---|---|
committer | Michal Minar <miminar@redhat.com> | 2013-08-27 12:32:42 +0200 |
commit | 74fb3cb4a410cd5650928de0e855dcaa6f7c83c1 (patch) | |
tree | a98b0f847c64187e4e35f9bf9bd2b49b5a5abd27 | |
parent | 678c38d2729cd86297c2aedfae1538d1991cb94b (diff) | |
download | openlmi-providers-74fb3cb4a410cd5650928de0e855dcaa6f7c83c1.tar.gz openlmi-providers-74fb3cb4a410cd5650928de0e855dcaa6f7c83c1.tar.xz openlmi-providers-74fb3cb4a410cd5650928de0e855dcaa6f7c83c1.zip |
python: improved logging
Allowed to pass different logging configuration dictionary.
Changed behaviour, when [Log] Stderr = True. Now both logging to CIMOM
and to stderr are enabled. Previously only logging to stderr has been
done.
-rw-r--r-- | src/python/lmi/providers/cmpi_logging.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/python/lmi/providers/cmpi_logging.py b/src/python/lmi/providers/cmpi_logging.py index 8a1c1d7..1eb9e3a 100644 --- a/src/python/lmi/providers/cmpi_logging.py +++ b/src/python/lmi/providers/cmpi_logging.py @@ -290,7 +290,7 @@ def trace_method(func, frame_level=1): """ Convenience function used for decorating methods. """ return trace_function_or_method(True, frame_level + 1)(func) -def setup(env, config): +def setup(env, config, default_logging_dict=None): """ Set up the logging with options given by SoftwareConfiguration instance. This should be called at process's startup before any message is sent to @@ -300,6 +300,11 @@ def setup(env, config): from CIMOM callback (e.g. ``get_providers()``). :param config: (``BaseConfiguration``) Configuration with Log section containing settings for logging. + :param default_logging_dict: (``dict``) Dictionary with default logging + configuration. If ``None``, ``DEFAULT_LOGGING_CONFIG`` will be used. If + given, it must contain at least "root" entry for root logger and + predefined "cmpi" and "stderr" handlers for logging to CIMOM and to + stderr. """ cp = config.config logging_setup = False @@ -316,10 +321,13 @@ def setup(env, config): logging.getLogger(__name__).exception( 'failed to setup logging from FileConfig') if logging_setup is False: - defaults = DEFAULT_LOGGING_CONFIG.copy() + if default_logging_dict is None: + defaults = DEFAULT_LOGGING_CONFIG.copy() + else: + defaults = default_logging_dict defaults["handlers"]["cmpi"]["cmpi_logger"] = env.get_logger() if config.stderr: - defaults["root"]["handlers"] = ["stderr"] + defaults["root"]["handlers"].append("stderr") level = config.logging_level if not level in LOGGING_LEVELS: logging.getLogger(__name__).error( |