32#include <spdlog/logger.h>
33#include <spdlog/spdlog.h>
35#include <pdi/pdi_fwd.h>
36#include <pdi/paraconf_wrapper.h>
44 std::shared_ptr<spdlog::logger> m_logger;
47 std::vector<std::reference_wrapper<Logger>> m_default_pattern_observers;
50 std::vector<std::string> m_pattern_blocks;
53 std::string m_pattern =
"[%T][%n] *** %^%l%$: %v";
56 bool m_pattern_from_config =
false;
62 Logger* m_parent_logger =
nullptr;
73 Logger(
const std::string& logger_name, PC_tree_t config, spdlog::level::level_enum level = spdlog::level::info);
86 Logger(
Logger& parent_logger,
const std::string& logger_name, PC_tree_t config);
93 void setup(
const std::string& logger_name, PC_tree_t config, spdlog::level::level_enum level = spdlog::level::info);
100 void setup(
Logger& parent_logger,
const std::string& logger_name, PC_tree_t config);
146 void level(spdlog::level::level_enum log_level);
151 spdlog::level::level_enum
level()
const;
174 template<
typename... Args>
175 void trace(
const char* fmt, Args&& ... args)
177 m_logger->trace(fmt, std::forward<Args>(args)...);
184 template<
typename... Args>
185 void debug(
const char* fmt, Args&& ... args)
187 m_logger->debug(fmt, std::forward<Args>(args)...);
194 template<
typename... Args>
195 void info(
const char* fmt, Args&& ... args)
197 m_logger->info(fmt, std::forward<Args>(args)...);
204 template<
typename... Args>
205 void warn(
const char* fmt, Args&& ... args)
207 m_logger->warn(fmt, std::forward<Args>(args)...);
214 template<
typename... Args>
215 void error(
const char* fmt, Args&& ... args)
217 m_logger->error(fmt, std::forward<Args>(args)...);
Wrapper for spdlog::logger with additional pattern getter method.
Definition: logger.h:42
const std::string & pattern() const
Returns pattern of the logger.
Logger()=default
Creates new empty logger.
void setup(Logger &parent_logger, const std::string &logger_name, PC_tree_t config)
Sets up the logger with parent logger.
void level(spdlog::level::level_enum log_level)
Sets logger level.
void error(const char *fmt, Args &&... args)
Writes error level message.
Definition: logger.h:215
void default_pattern(const std::string &pattern)
Changes default pattern of the logger (won't be updated if current pattern is from config)
void debug(const char *fmt, Args &&... args)
Writes debug level message.
Definition: logger.h:185
void global_pattern(const std::string &pattern)
Changes pattern of the global logger.
Logger(Logger &parent_logger, const std::string &logger_name, PC_tree_t config)
Creates new logger with parent logger.
void warn(const char *fmt, Args &&... args)
Writes warning level message.
Definition: logger.h:205
void evaluate_global_pattern(Context &ctx) const
Evaluate global pattern.
Logger(const std::string &logger_name, PC_tree_t config, spdlog::level::level_enum level=spdlog::level::info)
Creates new logger.
void add_pattern_global_block(const std::string &block)
Add new element to default pattern of the global logger.
void trace(const char *fmt, Args &&... args)
Writes trace level message.
Definition: logger.h:175
void add_pattern_block(const std::string &block)
Add new element to default pattern.
void info(const char *fmt, Args &&... args)
Writes info level message.
Definition: logger.h:195
spdlog::level::level_enum level() const
Returns level of the logger.
void setup(const std::string &logger_name, PC_tree_t config, spdlog::level::level_enum level=spdlog::level::info)
Sets up the logger.
void pattern(const std::string &pattern)
Changes pattern of the logger.
void evaluate_pattern(Context &ctx) const
Evaluate pattern.
std::shared_ptr< spdlog::logger > real_logger()
Returns real spdlog logger.
Definition: array_datatype.h:38