Commit 75419289 authored by Matias Guijarro's avatar Matias Guijarro

logtools: automatically add object to map when _logger if called, if not registered yet

parent 1386ece5
......@@ -33,10 +33,11 @@ class LogMixin:
def _logger(self, *args, **kwargs):
m = session.get_current().map
id_ = id(self)
if id_ not in m.G:
return None
return m.G.node[id_]["_logger"]
id_ = map_id(self)
if id_ in m.G:
return m.G.node[id_]["_logger"]
n = m.register(self)
return n["_logger"]
def improve_logger(logger_instance):
......@@ -187,13 +187,9 @@ def test_LogMixin(params, caplog):
beacon, log = params
nmc = NotMappedController()
assert == "session.controllers.nmc"
mc = MappedController()
with pytest.raises(AttributeError):
with pytest.raises(AttributeError):
with pytest.raises(AttributeError):
assert == ""
mc._logger.debugon() # activates debug logging level
expected = "Debug message"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment