ANNA Suite  2020b
Multipurpose development suite for Telco applications
TraceMethod.hpp
Go to the documentation of this file.
1 // ANNA - Anna is Not Nothingness Anymore //
2 // //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
4 // //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
7 
8 
9 #ifndef anna_core_tracing_TraceMethod_hpp
10 #define anna_core_tracing_TraceMethod_hpp
11 
13 
14 namespace anna {
15 
22 class TraceMethod {
23 public:
35  TraceMethod(const char* className, const char* functionName, const char* fromFile, const int fromLine) :
36  a_level(Logger::Debug),
37  a_className(className),
38  a_functionName(functionName),
39  a_fromFile(fromFile),
40  a_ok(false) {
41  if((a_ok = Logger::isActive(a_level)) == true) {
42  std::string text(className);
43  text += "::";
44  text += functionName;
45  Logger::write(a_level, text, "begin", fromFile, fromLine);
46  }
47  }
48 
61  TraceMethod(const Logger::Level level, const char* className, const char* functionName, const char* fromFile, const int fromLine) :
62  a_level(level),
63  a_className(className),
64  a_functionName(functionName),
65  a_fromFile(fromFile) {
66  if((a_ok = Logger::isActive(level)) == true) {
67  std::string text(className);
68  text += "::";
69  text += functionName;
70  Logger::write(level, text, "begin", fromFile, fromLine);
71  }
72  }
73 
84  TraceMethod(const char* methodName, const char* fromFile, const int fromLine) :
85  a_level(Logger::Debug),
86  a_className(methodName),
87  a_functionName(NULL),
88  a_fromFile(fromFile),
89  a_ok(false) {
90  if((a_ok = Logger::isActive(a_level)) == true)
91  Logger::write(a_level, methodName, "begin", fromFile, fromLine);
92  }
93 
105  TraceMethod(const Logger::Level level, const char* methodName, const char* fromFile, const int fromLine) :
106  a_level(level),
107  a_className(methodName),
108  a_functionName(NULL),
109  a_fromFile(fromFile),
110  a_ok(false) {
111  if((a_ok = Logger::isActive(level)) == true)
112  Logger::write(level, methodName, "begin", fromFile, fromLine);
113  }
114 
119  if(a_ok == true && Logger::isActive(a_level) == true) {
120  std::string text(a_className);
121 
122  if(a_functionName != NULL) {
123  text += "::";
124  text += a_functionName;
125  }
126 
127  Logger::write(a_level, text, "end", a_fromFile, 0);
128  }
129  }
130 
131 private:
132  const Logger::Level a_level;
133  const char* a_className;
134  const char* a_functionName;
135  const char* a_fromFile;
136  bool a_ok;
137 };
138 
139 } //namespace anna
140 
141 #endif
142 
Level
Definition: Logger.hpp:39
Definition: Logger.hpp:30
TraceMethod(const Logger::Level level, const char *methodName, const char *fromFile, const int fromLine)
Definition: TraceMethod.hpp:105
TraceMethod(const char *methodName, const char *fromFile, const int fromLine)
Definition: TraceMethod.hpp:84
Definition: app.hpp:12
TraceMethod(const Logger::Level level, const char *className, const char *functionName, const char *fromFile, const int fromLine)
Definition: TraceMethod.hpp:61
TraceMethod(const char *className, const char *functionName, const char *fromFile, const int fromLine)
Definition: TraceMethod.hpp:35
Definition: TraceMethod.hpp:22
static void write(const Level level, const char *text, const char *fromFile, const int fromLine)
~TraceMethod()
Definition: TraceMethod.hpp:118
static bool isActive(const Level level)
Definition: Logger.hpp:169