Merge "Make Event logging more useful by default"

This commit is contained in:
Zuul 2019-05-23 19:10:20 +00:00 committed by Gerrit Code Review
commit ad69266e3f
3 changed files with 18 additions and 2 deletions

View File

@ -40,8 +40,8 @@ class RowEvent(ovsdb_event.RowEvent): # pylint: disable=abstract-method
return False
if not self.match_fn(event, row, old):
return False
LOG.debug("%s : Matched %s, %s, %s %s", self.event_name, self.table,
event, self.conditions, self.old_conditions)
LOG.debug("Matched %s: %r to row=%s old=%s", event.upper(), self,
idlutils.row2str(row), idlutils.row2str(old) if old else '')
return True

View File

@ -310,3 +310,14 @@ def db_replace_record(obj):
elif isinstance(obj, api.Command):
obj = obj.result
return obj
def row2str(row):
"""Get a string representation of a Row"""
# This is not a repr, as the Row object takes a dict of Datum objects and
# we don't really want to deal with those, just what the Python values are.
# Row foreign keys are printed as their UUID
return "%s(%s)" % (row._table.name, ", ".join(
"%s=%s" % (col, idl._row_to_uuid(getattr(row, col)))
for col in row._table.columns if hasattr(row, col)))

View File

@ -53,6 +53,11 @@ class RowEvent(object):
def __ne__(self, other):
return not self == other
def __repr__(self):
return "%s(events=%r, table=%r, conditions=%r, old_conditions=%r)" % (
self.__class__.__name__, self.events, self.table, self.conditions,
self.old_conditions)
@abc.abstractmethod
def matches(self, event, row, old=None):
"""Test that `event` on `row` matches watched events