summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichal Minar <miminar@redhat.com>2013-04-05 11:58:19 +0200
committerMichal Minar <miminar@redhat.com>2013-04-11 13:54:40 +0200
commitfd853469a2e2a34296f5088277c28edacdbe40f7 (patch)
treecaba420fe89992aa1b6f1829865a9e8a1ff9fbe4 /src
parent625a073a829f47ad548c65ad736f979c2f6f5b36 (diff)
downloadopenlmi-providers-fd853469a2e2a34296f5088277c28edacdbe40f7.tar.gz
openlmi-providers-fd853469a2e2a34296f5088277c28edacdbe40f7.tar.xz
openlmi-providers-fd853469a2e2a34296f5088277c28edacdbe40f7.zip
logging improvements
this relates mostly to YumWorker separated process that does not use cmpi_logging
Diffstat (limited to 'src')
-rw-r--r--src/software/openlmi/software/cimom_entry.py1
-rw-r--r--src/software/openlmi/software/yumdb/__init__.py3
-rw-r--r--src/software/openlmi/software/yumdb/util.py35
3 files changed, 31 insertions, 8 deletions
diff --git a/src/software/openlmi/software/cimom_entry.py b/src/software/openlmi/software/cimom_entry.py
index eaa7b0c..ad944c8 100644
--- a/src/software/openlmi/software/cimom_entry.py
+++ b/src/software/openlmi/software/cimom_entry.py
@@ -70,6 +70,7 @@ def get_providers(env):
"""
@return mapping of provider names to corresponding provider instances.
"""
+ cmpi_logging.LogManager.LOGGER_NAME = 'openlmi.software'
cmpi_logging.LogManager(env)
# jobmanager does not understand CIM models, give it a way to transform
diff --git a/src/software/openlmi/software/yumdb/__init__.py b/src/software/openlmi/software/yumdb/__init__.py
index bbf2364..04f2191 100644
--- a/src/software/openlmi/software/yumdb/__init__.py
+++ b/src/software/openlmi/software/yumdb/__init__.py
@@ -63,6 +63,7 @@ MAX_JOB_WAIT_TIME = 30
# this may be used as an argument to YumWorker to setup logging
YUM_WORKER_DEBUG_LOGGING_CONFIG = {
"version" : 1,
+ 'disable_existing_loggers' : True,
"formatters": {
# this is a message format for logging function/method calls
# it's manually set up in YumWorker's init method
@@ -86,7 +87,7 @@ YUM_WORKER_DEBUG_LOGGING_CONFIG = {
},
"loggers" : {
"root": {
- "level": "ERROR",
+ "level": "DEBUG",
"handlers" : ["file"]
},
"openlmi.software.yumdb": {
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
+ }
+ }
+ })
+