Elements 6.3.3
A C++ base framework for the Euclid Software.
Loading...
Searching...
No Matches
Logging.h
Go to the documentation of this file.
1
20
25
26#ifndef ELEMENTSKERNEL_ELEMENTSKERNEL_LOGGING_H_
27#define ELEMENTSKERNEL_ELEMENTSKERNEL_LOGGING_H_
28
29#include <sstream> // for stringstream
30#include <string> // for string
31
32#include <log4cpp/Category.hh> // for category
33#include <log4cpp/Priority.hh> // for Priority
34
35#include "ElementsKernel/Export.h" // ELEMENTS_API
36#include "ElementsKernel/Path.h" // for Item
37
38namespace Elements {
39
94
95private:
96 // We declare the LogMessageStream here because it is used from the public
97 // functions. It is defined in the private section at the end.
98 class LogMessageStream;
99
100public:
107 static Logging getLogger(const std::string& name = "");
108
119 static void setLevel(std::string level);
120
137 static void setLogFile(const Path::Item& fileName);
138
143 void debug(const std::string& logMessage);
144
150 template <typename... Args>
151 void debug(const char* stringFormat, Args&&... args);
152
159
164 void info(const std::string& logMessage);
165
171 template <typename... Args>
172 void info(const char* stringFormat, Args&&... args);
173
180
185 void warn(const std::string& logMessage);
186
192 template <typename... Args>
193 void warn(const char* stringFormat, Args&&... args);
194
201
206 void error(const std::string& logMessage);
207
213 template <typename... Args>
214 void error(const char* stringFormat, Args&&... args);
215
222
227 void fatal(const std::string& logMessage);
228
234 template <typename... Args>
235 void fatal(const char* stringFormat, Args&&... args);
236
243
249 void log(log4cpp::Priority::Value level, const std::string& logMessage);
250
257 template <typename... Args>
258 void log(log4cpp::Priority::Value level, const char* stringFormat, Args&&... args);
259
260private:
261 explicit Logging(log4cpp::Category& log4cppLogger);
262
263 log4cpp::Category& m_log4cppLogger;
264
276 // The P_log_func is a pointer to member function. If you have no idea what
277 // this is don't get scared! Just have a look in the following link:
278 // http://www.codeproject.com/Articles/7150/Member-Function-Pointers-and-the-Fastest-Possible
279 using P_log_func = void (log4cpp::Category::*)(const std::string&);
280
281 public:
282 LogMessageStream(log4cpp::Category& logger, P_log_func log_func);
283 LogMessageStream(LogMessageStream&& other) noexcept;
286
287 template <typename T>
289
290 private:
291 log4cpp::Category& m_logger;
294 };
295};
296
297} // namespace Elements
298
299#define ELEMENTSKERNEL_ELEMENTSKERNEL_LOGGING_IMPL_
300#include "ElementsKernel/_impl/Logging.tpp" // IWYU pragma: export
301#undef ELEMENTSKERNEL_ELEMENTSKERNEL_LOGGING_IMPL_
302
303#endif // ELEMENTSKERNEL_ELEMENTSKERNEL_LOGGING_H_
304
defines the macros to be used for explicit export of the symbols
implementation of the templates declared in ElementsKernel/Logging.h
provide functions to retrieve resources pointed by environment variables
A helper class for logging messages using the "<<" operator.
Definition Logging.h:275
LogMessageStream(log4cpp::Category &logger, P_log_func log_func)
LogMessageStream & operator<<(const T &m)
void(log4cpp::Category::*)(const std::string &) P_log_func
Definition Logging.h:279
log4cpp::Category & m_logger
Definition Logging.h:291
void error(const std::string &logMessage)
Definition Logging.cpp:134
void debug(const std::string &logMessage)
Definition Logging.cpp:110
void log(log4cpp::Priority::Value level, const char *stringFormat, Args &&... args)
static Logging getLogger(const std::string &name="")
Definition Logging.cpp:75
void warn(const std::string &logMessage)
Definition Logging.cpp:126
static void setLogFile(const Path::Item &fileName)
Sets the file to store the log messages.
Definition Logging.cpp:99
static void setLevel(std::string level)
Sets the global message level.
Definition Logging.cpp:87
log4cpp::Category & m_log4cppLogger
Definition Logging.h:263
void log(log4cpp::Priority::Value level, const std::string &logMessage)
Definition Logging.cpp:149
void fatal(const char *stringFormat, Args &&... args)
void warn(const char *stringFormat, Args &&... args)
void debug(const char *stringFormat, Args &&... args)
Logging(log4cpp::Category &log4cppLogger)
Definition Logging.cpp:73
void fatal(const std::string &logMessage)
Definition Logging.cpp:141
void error(const char *stringFormat, Args &&... args)
void info(const std::string &logMessage)
Definition Logging.cpp:118
void info(const char *stringFormat, Args &&... args)
#define ELEMENTS_API
Dummy definitions for the backward compatibility mode.
Definition Export.h:74