I want to write a class that will show me the tree of currently working functions, that means:
Let's say I have function A call function B first and then function C, and function C calls function D. At time t = 1, B is running, so I want the stdout to be:
Root: function A -> running properly, called B
2-nd: function B -> running properly
At time t = 2, B has returned to A, so the stdout becomes:
Root: function A -> running properly, B returned
At time t = 3, A has called C. At time t = 4, C has called D. The stdout should be:
Root: function A -> running properly, B returned, called C
2-nd: function C -> running properly, called D
3-rd: function D -> running properly
At time t = 5, D returned. At time t = 6, C returned. The stdout should be:
Root: function A -> running properly, B returned, C returned
At time t = 7, function A returned:
Root: function A -> Done
Besides creating a logger object and passing it around, is there a more elegant way to automate this? What if A or B is a multithreaded process?
Any suggestions is much appreciated. Thank you!