30#include <boost/algorithm/string.hpp>
32#include <log4cpp/Category.hh>
33#include <log4cpp/FileAppender.hh>
34#include <log4cpp/OstreamAppender.hh>
35#include <log4cpp/PatternLayout.hh>
36#include <log4cpp/Priority.hh>
47using log4cpp::Category;
49using log4cpp::Priority;
58 {
"FATAL", Priority::FATAL},
59 {
"ERROR", Priority::ERROR},
60 {
"WARN", Priority::WARN},
61 {
"INFO", Priority::INFO},
62 {
"DEBUG", Priority::DEBUG}
69 layout->setConversionPattern(
"%d{%FT%T%Z} %c %5p : %m%n");
76 if (Category::getRoot().getAppender(
"console") ==
nullptr) {
77 auto* consoleAppender =
new log4cpp::OstreamAppender{
"console", &
std::cerr};
79 Category::getRoot().addAppender(consoleAppender);
80 if (Category::getRoot().getPriority() == Priority::NOTSET) {
81 Category::setRootPriority(Priority::INFO);
84 return Logging{Category::getInstance(name)};
88 boost::to_upper(level);
91 Category::setRootPriority(it->second);
94 error_buffer <<
"Unrecognized logging level: " << level <<
std::endl;
100 Category& root = Category::getRoot();
101 root.removeAppender(root.getAppender(
"file"));
102 if (fileName.has_filename()) {
103 auto* fileAppender =
new log4cpp::FileAppender(
"file", fileName.string());
105 root.addAppender(fileAppender);
107 root.setPriority(root.getPriority());
155 : m_logger(logger), m_log_func{log_func} {}
159 : m_logger(other.m_logger), m_log_func{other.m_log_func} {}
162 : m_logger(other.m_logger), m_log_func{other.m_log_func} {}
165 (m_logger.*m_log_func)(m_message.str());
This file is intended to iron out all the differences between different C++ standards.
defines the base Elements exception class
provide functions to retrieve configuration files
provide functions to retrieve resources pointed by environment variables
Elements base exception class.
A helper class for logging messages using the "<<" operator.
LogMessageStream(log4cpp::Category &logger, P_log_func log_func)
Logging API of the Elements framework.
static Logging getLogger(const std::string &name="")
static void setLogFile(const Path::Item &fileName)
Sets the file to store the log messages.
static void setLevel(std::string level)
Sets the global message level.
log4cpp::Category & m_log4cppLogger
void log(log4cpp::Priority::Value level, const std::string &logMessage)
Logging(log4cpp::Category &log4cppLogger)
#define NON_REDUNDANT_MOVE(x)
ELEMENTS_API std::unique_ptr< T > make_unique(Args &&... args)
Constructs an object of type T and wraps it in a std::unique_ptr using args as the parameter list for...
unique_ptr< Layout > getLogLayout()
static const std::map< string, const int > LOG_LEVEL