-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
When there is a class hierarchy and a log_action() is on a method in the base class, if two different instances of different subclasses of that base class are created and the base class function is invoked on each, the logger will log the subclass name of the instance that was invoked first on all invocations of the function on either instance.
Expected behaviour: the logger should log the correct classname appropriate for each subclass.
from nhs_context_logging import log_action
from nhs_context_logging.fixtures import *
class BaseClass:
@log_action()
def base_function(self):
print(self.__class__, "base_function()")
class SubClassA(BaseClass):
...
class SubClassB(BaseClass):
...
def test_logging(log_capture):
stdout, _ = log_capture
a = SubClassA()
a.base_function()
b = SubClassB()
b.base_function()
for line in stdout:
print("Action:", line["action"])
Results in
<class 'testtest.SubClassA'> base_function()
<class 'testtest.SubClassB'> base_function()
Action: SubClassA.base_function
Action: SubClassA.base_function
The final line should be for SubClassB, but is using action from the initial call to SubClassA.
Expected
<class 'testtest.SubClassA'> base_function()
<class 'testtest.SubClassB'> base_function()
Action: SubClassA.base_function
Action: SubClassB.base_function
Metadata
Metadata
Assignees
Labels
No labels