Class as wrapper and initializer for a globally usable logger.
More...
#include <Logger.h>
|
static std::shared_ptr< spdlog::logger > | logger = init_logger() |
| Publically accessible shared pointer to the logger. More...
|
|
Class as wrapper and initializer for a globally usable logger.
Definition at line 18 of file Logger.h.
◆ LogType
Enum for the type of logger.
Definition at line 23 of file Logger.h.
◆ init_logger()
Initializes the logger.
Definition at line 23 of file Logger.cpp.
24 auto standard_out = std::make_shared<spdlog::sinks::stdout_color_sink_mt>();
25 standard_out->set_color(spdlog::level::critical, standard_out->dark);
26 standard_out->set_color(spdlog::level::err, standard_out->red);
27 standard_out->set_color(spdlog::level::warn, standard_out->yellow);
28 standard_out->set_color(spdlog::level::info, standard_out->green);
29 standard_out->set_color(spdlog::level::debug, standard_out->blue);
30 standard_out->set_color(spdlog::level::trace, standard_out->magenta);
32 spdlog::init_thread_pool(8192, 1);
33 std::shared_ptr<spdlog::logger> new_logger;
36 new_logger = spdlog::rotating_logger_st(
"file_logger",
"logs/log", 1048576 * 5, 3);
39 std::make_shared<spdlog::async_logger>(
"std_logger", standard_out, spdlog::thread_pool(), spdlog::async_overflow_policy::block);
42 new_logger->set_level(spdlog::level::off);
43 new_logger->set_pattern(
"[%H:%M:%S] %^[%l]%$ %v");
void createDirectory(const std::string &dir_name)
◆ update_level()
void Logger::update_level |
( |
std::string & |
log_level | ) |
|
|
static |
Sets the log level of the logger.
- Parameters
-
log_level | The log level to set |
Definition at line 48 of file Logger.cpp.
49 if (log_level ==
"trace") {
51 }
else if (log_level ==
"debug") {
53 }
else if (log_level ==
"info") {
55 }
else if (log_level ==
"warning") {
57 }
else if (log_level ==
"error") {
59 }
else if (log_level ==
"critical") {
60 logger->set_level(spdlog::level::critical);
61 }
else if (log_level ==
"off") {
64 std::cout <<
"Error: Invalid log level given." << std::endl;
65 throw std::invalid_argument(
"Invalid log level given.");
static std::shared_ptr< spdlog::logger > logger
Publically accessible shared pointer to the logger.
◆ logger
std::shared_ptr< spdlog::logger > Logger::logger = init_logger() |
|
static |
Publically accessible shared pointer to the logger.
- Returns
- Logger
Definition at line 35 of file Logger.h.
The documentation for this class was generated from the following files: