2019-06-04 05:09:16 +08:00
|
|
|
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
2019-05-12 01:06:17 +08:00
|
|
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
2019-05-12 06:12:46 +08:00
|
|
|
|
2023-09-29 05:20:26 +08:00
|
|
|
#include "spdlog/spdlog.h"
|
|
|
|
|
2023-10-01 17:20:48 +08:00
|
|
|
#include <memory>
|
|
|
|
|
2023-09-29 05:05:17 +08:00
|
|
|
#include "spdlog/common.h"
|
2023-10-01 17:20:48 +08:00
|
|
|
#include "spdlog/logger.h"
|
2023-09-29 05:05:17 +08:00
|
|
|
#include "spdlog/pattern_formatter.h"
|
2023-10-01 17:20:48 +08:00
|
|
|
#include "spdlog/sinks/stdout_color_sinks.h"
|
2023-09-25 01:26:32 +08:00
|
|
|
|
|
|
|
namespace spdlog {
|
|
|
|
|
2024-12-06 15:53:23 +08:00
|
|
|
|
2024-03-16 23:12:46 +08:00
|
|
|
|
2023-09-25 07:35:55 +08:00
|
|
|
void set_formatter(std::unique_ptr<spdlog::formatter> formatter) {
|
2024-12-06 15:53:23 +08:00
|
|
|
default_logger_raw()->set_formatter(std::move(formatter));
|
2023-09-25 01:26:32 +08:00
|
|
|
}
|
|
|
|
|
2023-09-25 07:35:55 +08:00
|
|
|
void set_pattern(std::string pattern, pattern_time_type time_type) {
|
2023-10-01 23:01:02 +08:00
|
|
|
set_formatter(std::make_unique<spdlog::pattern_formatter>(std::move(pattern), time_type));
|
2023-09-25 01:26:32 +08:00
|
|
|
}
|
|
|
|
|
2023-09-25 07:35:55 +08:00
|
|
|
level get_level() { return default_logger_raw()->log_level(); }
|
2023-09-25 01:26:32 +08:00
|
|
|
|
2023-09-25 07:35:55 +08:00
|
|
|
bool should_log(level level) { return default_logger_raw()->should_log(level); }
|
2023-09-25 01:26:32 +08:00
|
|
|
|
2024-12-06 15:53:23 +08:00
|
|
|
void set_level(level level) { default_logger_raw()->set_level(level); }
|
2023-09-25 01:26:32 +08:00
|
|
|
|
2024-12-06 15:53:23 +08:00
|
|
|
void flush_on(level level) { default_logger_raw()->flush_on(level); }
|
2023-09-25 01:26:32 +08:00
|
|
|
|
2024-12-06 15:53:23 +08:00
|
|
|
void set_error_handler(void (*handler)(const std::string &msg)) { default_logger_raw()->set_error_handler(handler); }
|
2023-09-25 01:26:32 +08:00
|
|
|
|
|
|
|
|
2024-12-06 15:13:47 +08:00
|
|
|
void shutdown() { details::context::instance().shutdown(); }
|
2023-09-25 01:26:32 +08:00
|
|
|
|
2024-12-06 15:13:47 +08:00
|
|
|
std::shared_ptr<spdlog::logger> default_logger() { return details::context::instance().default_logger(); }
|
2023-09-25 01:26:32 +08:00
|
|
|
|
2024-12-06 15:13:47 +08:00
|
|
|
spdlog::logger *default_logger_raw() { return details::context::instance().get_default_raw(); }
|
2023-09-25 01:26:32 +08:00
|
|
|
|
2023-09-25 07:35:55 +08:00
|
|
|
void set_default_logger(std::shared_ptr<spdlog::logger> default_logger) {
|
2024-12-06 15:13:47 +08:00
|
|
|
details::context::instance().set_default_logger(std::move(default_logger));
|
2023-09-25 01:26:32 +08:00
|
|
|
}
|
|
|
|
|
2023-09-25 21:40:05 +08:00
|
|
|
} // namespace spdlog
|