shadPS4/src/Util/log.cpp

25 lines
1007 B
C++
Raw Normal View History

2023-08-13 15:54:56 +02:00
#include <spdlog/common.h>
#include <spdlog/pattern_formatter.h>
2023-08-14 00:24:03 +02:00
#include <spdlog/sinks/basic_file_sink.h>
#include <spdlog/sinks/stdout_color_sinks.h>
#include <spdlog/spdlog.h>
2023-08-13 15:54:56 +02:00
2023-08-14 00:24:03 +02:00
#include <vector>
2023-08-13 15:54:56 +02:00
namespace logging {
2023-08-14 00:24:03 +02:00
std::vector<spdlog::sink_ptr> sinks;
int init(bool use_stdout) {
sinks.clear(); // clear existing sinks
if (use_stdout) // if we use stdout window then init it as well
sinks.push_back(std::make_shared<spdlog::sinks::stdout_color_sink_mt>());
sinks.push_back(std::make_shared<spdlog::sinks::basic_file_sink_mt>(L"shadps4.txt", true));
spdlog::set_default_logger(std::make_shared<spdlog::logger>("shadps4 logger", begin(sinks), end(sinks)));
auto f = std::make_unique<spdlog::pattern_formatter>("%^|%L|: %v%$", spdlog::pattern_time_type::local, std::string("")); // disable eol
spdlog::set_formatter(std::move(f));
return 0; // all ok
}
2023-08-13 15:54:56 +02:00
2023-08-14 00:24:03 +02:00
void set_level(spdlog::level::level_enum log_level) { spdlog::set_level(log_level); }
2023-08-13 15:54:56 +02:00
2023-08-14 00:24:03 +02:00
} // namespace logging