1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-02 08:57:44 +00:00

add customisable log level to config

This commit is contained in:
NotAdam 2019-01-25 19:00:21 +11:00
parent 0988b3abac
commit 91abe63598
8 changed files with 18 additions and 0 deletions

View file

@ -12,6 +12,8 @@ ServerSecret = default
DataPath = C:\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack
WorldID = 67
DefaultGMRank = 255
LogLevel = 1
LogFilter = 0
[Network]
; Values definining how Users and other servers will access - these have to be set to your public IP when running a public server

View file

@ -713,6 +713,8 @@ int main( int argc, char* argv[] )
if( !loadSettings( argc, argv ) )
throw std::exception();
Logger::setLogLevel( m_config.global.general.logLevel );
server.resource[ "^/ZoneName/([0-9]+)$" ][ "GET" ] = &getZoneName;
server.resource[ "^/sapphire-api/lobby/createAccount" ][ "POST" ] = &createAccount;
server.resource[ "^/sapphire-api/lobby/login" ][ "POST" ] = &login;

View file

@ -16,6 +16,8 @@ namespace Sapphire::Common::Config
uint16_t worldID;
uint8_t defaultGMRank;
uint8_t logLevel;
uint32_t logFilter;
} general;
struct Network

View file

@ -57,6 +57,8 @@ bool Sapphire::ConfigMgr::loadGlobalConfig( Common::Config::GlobalConfig& config
config.general.serverSecret = getValue< std::string >( "General", "ServerSecret", "default" );
config.general.worldID = getValue< uint16_t >( "General", "WorldID", 67 );
config.general.defaultGMRank = getValue< uint8_t >( "General", "DefaultGMRank", 255 );
config.general.logLevel = getValue< uint8_t >( "General", "LogLevel", 1 );
config.general.logFilter = getValue< uint32_t >( "General", "LogFilter", 0 );
// network
config.network.zoneHost = getValue< std::string >( "Network", "ZoneHost", "127.0.0.1" );

View file

@ -53,6 +53,11 @@ namespace Sapphire
spdlog::flush_on( spdlog::level::critical );
}
void Logger::setLogLevel( uint8_t logLevel )
{
spdlog::set_level( static_cast< spdlog::level::level_enum >( logLevel ) );
}
void Logger::error( const std::string& text )
{
spdlog::get( "logger" )->error( text );

View file

@ -19,6 +19,7 @@ namespace Sapphire
public:
static void init( const std::string& logPath );
static void setLogLevel( uint8_t logLevel );
// todo: this is a minor increase in build time because of fmtlib, but much less than including spdlog directly

View file

@ -63,6 +63,8 @@ namespace Sapphire
return;
}
Logger::setLogLevel( m_config.global.general.logLevel );
auto pFw = std::make_shared< Framework >();
Network::HivePtr hive( new Network::Hive() );
Network::addServerToHive< Network::GameConnection >( m_ip, m_port, hive, pFw );

View file

@ -129,6 +129,8 @@ void Sapphire::World::ServerMgr::run( int32_t argc, char* argv[] )
return;
}
Logger::setLogLevel( m_config.global.general.logLevel );
Logger::info( "Setting up generated EXD data" );
auto pExdData = std::make_shared< Data::ExdDataGenerated >();
auto dataPath = m_config.global.general.dataPath;