mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-29 07:37:45 +00:00
Missing log-folder will now be created atomatically
This commit is contained in:
parent
2a6246f490
commit
c00b27712b
2 changed files with 67 additions and 58 deletions
|
@ -6,11 +6,13 @@
|
||||||
#include <spdlog/sinks/daily_file_sink.h>
|
#include <spdlog/sinks/daily_file_sink.h>
|
||||||
|
|
||||||
// #include <iostream>
|
// #include <iostream>
|
||||||
|
#include <experimental/filesystem> // or #include <filesystem>
|
||||||
|
|
||||||
|
namespace fs = std::experimental::filesystem;
|
||||||
|
|
||||||
namespace Core
|
namespace Core
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
Logger::Logger()
|
Logger::Logger()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -23,6 +25,14 @@ Logger::~Logger()
|
||||||
|
|
||||||
void Logger::setLogPath( const std::string& logPath )
|
void Logger::setLogPath( const std::string& logPath )
|
||||||
{
|
{
|
||||||
|
auto pos = logPath.find_last_of( '/' );
|
||||||
|
|
||||||
|
if( pos != std::string::npos )
|
||||||
|
{
|
||||||
|
std::string realPath = logPath.substr( 0, pos );
|
||||||
|
fs::create_directories( realPath );
|
||||||
|
}
|
||||||
|
|
||||||
m_logFile = logPath;
|
m_logFile = logPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,5 +78,4 @@ void Logger::fatal( const std::string& text )
|
||||||
spdlog::get( "logger" )->critical( text );
|
spdlog::get( "logger" )->critical( text );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ bool setupFramework()
|
||||||
auto pDebugCom = std::make_shared< DebugCommandHandler >();
|
auto pDebugCom = std::make_shared< DebugCommandHandler >();
|
||||||
auto pConfig = std::make_shared< ConfigMgr >();
|
auto pConfig = std::make_shared< ConfigMgr >();
|
||||||
|
|
||||||
pLogger->setLogPath( "log/SapphireZone_" );
|
pLogger->setLogPath( "log/SapphireZone" );
|
||||||
pLogger->init();
|
pLogger->init();
|
||||||
|
|
||||||
g_fw.set< ServerZone >( pServer );
|
g_fw.set< ServerZone >( pServer );
|
||||||
|
|
Loading…
Add table
Reference in a new issue