|author||Neels Hofmeyr <email@example.com>||2017-06-06 19:44:32 +0200|
|committer||Neels Hofmeyr <firstname.lastname@example.org>||2017-06-07 19:53:24 +0200|
fix problem in origin ancestry: don't add self twice
Also add various comments to illustrate what is going on during origin resolution. In the regression tests' expectations, some duplicate entries in the origins are removed, and hence no list of deeper origin ancestry is printed anymore. Change-Id: I42c3b8635b54c31c27699140e200c1f75a6ada29
Diffstat (limited to 'src/osmo_gsm_tester/log.py')
1 files changed, 10 insertions, 0 deletions
diff --git a/src/osmo_gsm_tester/log.py b/src/osmo_gsm_tester/log.py
index ede3b16..fb6d55b 100644
@@ -352,10 +352,20 @@ class Origin:
origins = Origins()
+ # this object shall always be seen as the immediate origin of the log message.
+ # now go through the parents of this object.
origin = self._parent_origin
+ # but if this object is "loose" and not set up with cascaded 'with' statements,
+ # take the last seen 'with' statement's object as next parent:
if origin is None and Origin._global_current_origin is not None:
origin = Origin._global_current_origin
+ # if this object is currently the _global_current_origin, we don't
+ # need to add it twice.
+ if origin is self:
+ origin = origin._parent_origin
+ # whichever we determined to be the parent above, go up through all its
+ # ancestors.
while origin is not None:
origin = origin._parent_origin