Osmocom GSM Tester, jenkins integrated GSM hardware testing https://osmocom.org/projects/osmo-gsm-tester
Go to file
Neels Hofmeyr 1a7a3f0e43 fix and refactor logging: drop 'with', simplify
With the recent fix of the junit report related issues, another issue arose:
the 'with log.Origin' was changed to disallow __enter__ing an object twice to
fix problems, now still code would fail because it tries to do 'with' on the
same object twice. The only reason is to ensure that logging is associated with
a given object. Instead of complicating even more, implement differently.

Refactor logging to simplify use: drop the 'with Origin' style completely, and
instead use the python stack to determine which objects are created by which,
and which object to associate a log statement with.

The new way: we rely on the convention that each class instance has a local
'self' referencing the object instance. If we need to find an origin as a new
object's parent, or to associate a log message with, we traverse each stack
frame, fetching the first local 'self' object that is a log.Origin class
instance.

How to use:

Simply call log.log() anywhere, and it finds an Origin object to log for, from
the stack. Alternatively call self.log() for any Origin() object to skip the
lookup.

Create classes as child class of log.Origin and make sure to call
super().__init__(category, name). This constructor will magically find a parent
Origin on the stack.

When an exception happens, we first escalate the exception up through call
scopes to where ever it is handled by log.log_exn(). This then finds an Origin
object in the traceback's stack frames, no need to nest in 'with' scopes.

Hence the 'with log.Origin' now "happens implicitly", we can write pure natural
python code, no more hassles with scope ordering.

Furthermore, any frame can place additional logging information in a frame by
calling log.ctx(). This is automatically inserted in the ancestry associated
with a log statement / exception.

Change-Id: I5f9b53150f2bb6fa9d63ce27f0806f0ca6a45e90
2017-06-13 13:32:01 +02:00
contrib jenkins: extract common parts of build scripts to separate file 2017-06-02 16:58:37 +02:00
doc MSC+BSC: add test api to run OsmoMSC and OsmoBSC with AoIP 2017-05-29 00:19:45 +02:00
example default suites: enable osmo-bts-trx (Ettus B210) 2017-05-29 21:43:10 +00:00
install initial import 2017-03-28 12:37:17 +02:00
selftest fix and refactor logging: drop 'with', simplify 2017-06-13 13:32:01 +02:00
src fix and refactor logging: drop 'with', simplify 2017-06-13 13:32:01 +02:00
suites ofono_client: Implement network registration during connect() 2017-06-12 15:34:21 +02:00
.gitignore Add JUnit XML reports; refactor test reporting 2017-05-19 14:22:39 +02:00
COPYING Add GPLv3 license text to repository 2017-06-03 14:23:51 +00:00
Makefile core implementation 2017-04-08 15:43:19 +02:00
check_dependencies.py core implementation 2017-04-08 15:43:19 +02:00
update_version.sh initial import 2017-03-28 12:37:17 +02:00