25 #ifndef LOG4CPP_LOGGER_H 26 #define LOG4CPP_LOGGER_H 28 #include "log4cpp/ILogHandler.h" 29 #include "log4cpp/Strings.h" 37 const uint32_t max_log_entry_size = 120;
55 Logger(
const std::shared_ptr<ILogHandler>& backend,
ModuleId moduleid,
const std::string&
id,
LogLevels levels) :
57 settings(std::make_shared<
Settings>(moduleid, id, levels))
65 void log(
const LogLevel& level,
const char* location,
const char* message)
70 this->settings->module,
71 this->settings->id.c_str(),
79 Logger detach(
const std::string&
id)
const 81 return Logger(this->backend, std::make_shared<Settings>(this->settings->module,
id, this->settings->levels));
84 template <
typename... Args>
85 Logger detach_and_append(Args... args)
const 87 return detach(Strings::concatenate(this->settings->id, args...));
90 Logger detach(
const std::string&
id, LogLevels levels)
const 92 return Logger(this->backend, std::make_shared<Settings>(this->settings->module,
id, levels));
95 Logger detach(LogLevels levels)
const 97 return Logger(this->backend, std::make_shared<Settings>(this->settings->module, this->settings->id, levels));
100 bool is_enabled(
const LogLevel& level)
const 102 return backend && settings->levels.is_set(level);
105 LogLevels get_levels()
const 107 return this->settings->levels;
110 void set_levels(
const LogLevels& filters)
112 this->settings->levels = filters;
115 void rename(
const std::string&
id)
117 this->settings->id = id;
121 Logger(
const std::shared_ptr<ILogHandler>& backend,
const std::shared_ptr<Settings>& settings) :
127 Logger& operator=(
const Logger&) =
delete;
129 const std::shared_ptr<ILogHandler> backend;
130 const std::shared_ptr<Settings> settings;
135 #endif //LOG4CPP_LOGGER_H
log4cpp header-only library namespace