Redirect error messages from libvirt to debug logger

- Add debug level to devops logger. Without this debug messages
  are skipped

Related-Bug: #1578280
Change-Id: I72dee9c2072da7d2658c1f159696c583184839b8
This commit is contained in:
Anton Studenov
2016-06-30 14:40:46 +03:00
parent f3583d416f
commit cbbab44b57
2 changed files with 9 additions and 0 deletions

View File

@@ -29,6 +29,7 @@ LOGGER_SETTINGS = {
'disable_existing_loggers': False,
'loggers': {
'devops': {
'level': 'DEBUG',
'handlers': ['log_file', 'console_output'],
},
},

View File

@@ -50,6 +50,7 @@ class _LibvirtManager(object):
def __init__(self):
libvirt.virInitialize()
libvirt.registerErrorHandler(_LibvirtManager._error_handler, self)
self.connections = {}
def get_connection(self, connection_string):
@@ -64,6 +65,13 @@ class _LibvirtManager(object):
conn = self.connections[connection_string]
return conn
def _error_handler(self, error):
# this handler redirects libvirt messages to debug logger
if len(error) > 2 and error[2] is not None:
logger.debug(error[2])
else:
logger.debug(error)
LibvirtManager = _LibvirtManager()