1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-25 22:17:45 +00:00

fix file extension for log files & always flush log on critical messages

This commit is contained in:
NotAdam 2018-10-25 15:39:36 +11:00
parent 1b267f55d3
commit 9c3ff73bf6

View file

@ -30,10 +30,15 @@ void Logger::init()
std::vector< spdlog::sink_ptr > sinks;
sinks.push_back( std::make_shared< spdlog::sinks::stdout_color_sink_mt >() );
sinks.push_back( std::make_shared< spdlog::sinks::daily_file_sink_mt >( m_logFile, 0, 0 ) );
sinks.push_back( std::make_shared< spdlog::sinks::daily_file_sink_mt >( m_logFile + ".log", 0, 0 ) );
m_logger = std::make_shared< spdlog::logger >( "logger", std::begin( sinks ), std::end( sinks ) );
// always flush the log on criticial messages, otherwise it's done by libc
// see: https://github.com/gabime/spdlog/wiki/7.-Flush-policy
// nb: if the server crashes, log data can be missing from the file unless something logs critical just before it does
m_logger->flush_on( spdlog::level::critical );
//spdlog::set_pattern( "[%H:%M:%S] [%l] %v" );
}