MachineIntelligenceCore:Toolchain
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ScopeLogger.hpp
Go to the documentation of this file.
1 
24 #ifndef SCOPELOGGER_HPP_
25 #define SCOPELOGGER_HPP_
26 
27 #include <logger/Logger.hpp>
28 
29 namespace mic {
30 namespace logger {
31 
38 {
39 public:
47  ScopeLogger(Logger * p_, const std::string & f_, int l_, Severity_t s_) :
48  parent(p_), file(f_), line(l_), severity(s_)
49  {
50 
51  }
52 
57  parent->log(file, line, severity, os.str());
58  }
59 
63  std::ostringstream& get()
64  {
65  return os;
66  }
67 
68 protected:
72  std::ostringstream os;
73 
74 private:
79  ScopeLogger(const ScopeLogger & rhs) : parent(rhs.parent) {
80  line = -1;
81  severity = LTRACE;
82  }
83 
85  return *this;
86  }
87 
88 private:
91 
93  const std::string file;
94 
96  int line;
97 
100 
101 };
102 
103 
104 } /* namespace logger */
105 } /* namespace mic */
106 
107 
108 #endif /* SCOPELOGGER_HPP_ */
Logger - defined in the form of a singleton, with double-checked locking pattern (DCLP) based access ...
Definition: Logger.hpp:47
Severity_t
Message severity level.
Definition: LoggerAux.hpp:35
void log(const std::string &file, int line, Severity_t sev, const std::string &msg)
Definition: Logger.cpp:67
Severity_t severity
Log (message) severity.
Definition: ScopeLogger.hpp:99
Logger * parent
Parent class, to which the information will be sent.
Definition: ScopeLogger.hpp:90
ScopeLogger & operator=(const ScopeLogger &)
Definition: ScopeLogger.hpp:84
std::ostringstream os
Definition: ScopeLogger.hpp:72
Contains declaration of a logger, a singleton responsible for logging and displaying all kinds of mes...
ScopeLogger(const ScopeLogger &rhs)
Definition: ScopeLogger.hpp:79
#define LTRACE
Definition: LoggerAux.hpp:52
const std::string file
Name of the file which called the logger.
Definition: ScopeLogger.hpp:93
int line
Number of the file line in which the logger was called.
Definition: ScopeLogger.hpp:96
Small class used to prepare line for logger. Object created only for the purpose of parsing the ostri...
Definition: ScopeLogger.hpp:37
ScopeLogger(Logger *p_, const std::string &f_, int l_, Severity_t s_)
Definition: ScopeLogger.hpp:47