Commit 576f8a37 authored by captainwong's avatar captainwong

fix log2 for unix

parent 11216891
......@@ -47,7 +47,13 @@ namespace jlib {
static constexpr char g_logger_name[] = "jlogger";
inline void init_logger(const std::wstring& file_name = L"")
inline void init_logger(const
#ifdef WIN32
std::wstring
#else
std::string
#endif
& file_name = L"")
{
try {
std::vector<spdlog::sink_ptr> sinks;
......@@ -55,7 +61,13 @@ inline void init_logger(const std::wstring& file_name = L"")
sinks.push_back(std::make_shared<spdlog::sinks::msvc_sink_mt>());
#endif
sinks.push_back(std::make_shared<spdlog::sinks::stdout_sink_mt>());
sinks.push_back(std::make_shared<spdlog::sinks::daily_file_sink_mt>(file_name + L".log", 23, 59));
sinks.push_back(std::make_shared<spdlog::sinks::daily_file_sink_mt>(
#ifdef WIN32
file_name + L".log"
#else
file_name + ".log"
#endif
, 23, 59));
auto combined_logger = std::make_shared<spdlog::logger>(g_logger_name, begin(sinks), end(sinks));
combined_logger->set_pattern("[%Y-%m-%d %H:%M:%S.%e] [tid %t] [%L] %v");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment