diff options
Diffstat (limited to 'src/software/openlmi/software/yumdb/util.py')
-rw-r--r-- | src/software/openlmi/software/yumdb/util.py | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/src/software/openlmi/software/yumdb/util.py b/src/software/openlmi/software/yumdb/util.py index bd2a0ca..a1ab338 100644 --- a/src/software/openlmi/software/yumdb/util.py +++ b/src/software/openlmi/software/yumdb/util.py @@ -28,7 +28,7 @@ import inspect import logging import os -from openlmi.software.yumdb import errors +from openlmi.common import cmpi_logging class DispatchingFormatter: """ @@ -117,11 +117,12 @@ def trace_function(func): logger.debug("%(caller_file)s:%(caller_lineno)d - %(action)s" " %(module)s:%(func)s:%(lineno)d", logargs) except Exception as exc: - logargs['action'] = 'exiting' - logargs['error'] = str(exc) - logger.debug("%(caller_file)s:%(caller_lineno)d - %(action)s" - " %(module)s:%(func)s:%(lineno)d with error: %(error)s", - logargs) + if logger.isEnabledFor(logging.DEBUG): + logargs['action'] = 'exiting' + logargs['error'] = str(exc) + logger.debug("%(caller_file)s:%(caller_lineno)d - %(action)s" + " %(module)s:%(func)s:%(lineno)d with error: %(error)s", + logargs) raise return result @@ -136,7 +137,27 @@ def setup_logging(config): """ try: logging.config.dictConfig(config) + cmpi_logging.logger = logging.getLogger('openlmi.software.yumdb') except Exception: #pylint: disable=W0703 # logging is not set up but client expects us to work - pass + # all messages are dumped to /dev/null + logging.config.dictConfig({ + 'version' : 1, + 'disable_existing_loggers' : True, + 'handlers': { + 'null' : { + 'class': 'logging.handlers.FileHandler', + 'level': 'CRITICAL', + 'filename': '/dev/null' + } + }, + 'loggers' : { + 'root' : { + 'level': 'CRITICAL', + 'handlers' : ['null'], + 'propagate' : False + } + } + }) + |