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:
@@ -29,6 +29,7 @@ LOGGER_SETTINGS = {
|
||||
'disable_existing_loggers': False,
|
||||
'loggers': {
|
||||
'devops': {
|
||||
'level': 'DEBUG',
|
||||
'handlers': ['log_file', 'console_output'],
|
||||
},
|
||||
},
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user