33 lines
903 B
C++
33 lines
903 B
C++
#include "application.h"
|
|
|
|
#include <iostream>
|
|
|
|
#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 {
|
|
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;
|
|
}
|
|
|
|
singleton_manager::get()->init();
|
|
}
|
|
|
|
void application::shutdown() {
|
|
singleton_manager::get()->release();
|
|
spdlog::drop_all();
|
|
spdlog::shutdown();
|
|
async_spdlog_.reset();
|
|
}
|
|
|
|
void application::request_exit() {
|
|
}
|