path: root/src
diff options
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-06-06 19:44:32 +0200
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-06-07 19:53:24 +0200
commit31e83200b21ab0c09112cb2815438e6259f1c874 (patch)
treed8ad53e332661215c5a2b7775caaca183053bda6 /src
parentd3a33e393ed8aba2df26cf0d4473cf46c5182090 (diff)
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')
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
--- a/src/osmo_gsm_tester/log.py
+++ b/src/osmo_gsm_tester/log.py
@@ -352,10 +352,20 @@ class Origin:
def gather_origins(self):
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