修复日志无法落地的bug

This commit is contained in:
Nanako 2024-03-24 01:30:55 +08:00
parent 0d73da1657
commit d81d1b24d4

View File

@ -4,11 +4,16 @@
#include "misc/singleton/singleton_manager.h"
#include "spdlog/async.h"
#include "spdlog/spdlog.h"
#include "spdlog/sinks/basic_file_sink.h"
#include "spdlog/sinks/rotating_file_sink.h"
void application::init(const char* runtime_dir) {
try {
async_spdlog_ = spdlog::basic_logger_mt<spdlog::async_factory>("async_file_logger", "logs/log.txt");
auto max_size = 1048576 * 10; // 10MB
auto max_files = 3;
async_spdlog_ = spdlog::rotating_logger_mt<spdlog::async_factory>("async_rotating_logger", "logs/log.txt", max_size, max_files);
spdlog::set_default_logger(async_spdlog_);
} catch (const spdlog::spdlog_ex& ex) {
std::cout << "Log init failed: " << ex.what() << std::endl;
}
@ -18,6 +23,9 @@ void application::init(const char* runtime_dir) {
void application::shutdown() {
singleton_manager::get()->release();
spdlog::drop_all();
spdlog::shutdown();
async_spdlog_.reset();
}
void application::request_exit() {