fork download
  1. #include <iostream>
  2.  
  3. class Logger
  4. {
  5. std::string _entry;
  6. public:
  7. Logger(std::string entry)
  8. {
  9. _entry = entry;
  10. std::cout << "Starting execution of " << entry << std::endl;
  11. }
  12.  
  13. ~Logger()
  14. {
  15. std::cout << "Ending execution of " << _entry << std::endl;
  16. }
  17. };
  18.  
  19. class A
  20. {
  21. public:
  22. void foo()
  23. {
  24. std::cout << "Doing foo" << std::endl;
  25. }
  26. };
  27.  
  28. #define CALL_FUNC_AND_LOG(obj,func) \
  29.   { \
  30.   Logger _mylogger(""#func); \
  31.   obj.func(); \
  32.   \
  33.   }
  34.  
  35. int main()
  36. {
  37. A a;
  38. CALL_FUNC_AND_LOG(a,foo);
  39. return 0;
  40. }
  41.  
Success #stdin #stdout 0s 3272KB
stdin
Standard input is empty
stdout
Starting execution of foo
Doing foo
Ending execution of foo