mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-27 22:57:45 +00:00
add logger message formatting
This commit is contained in:
parent
dfc43dfae6
commit
a140eeac4c
5 changed files with 55 additions and 19 deletions
|
@ -47,9 +47,8 @@ void Sapphire::Db::DbWorkerPool< T >::setConnectionInfo( const ConnectionInfo& i
|
|||
template< class T >
|
||||
uint32_t Sapphire::Db::DbWorkerPool< T >::open()
|
||||
{
|
||||
Logger::info( "[DbPool] Opening DatabasePool " + getDatabaseName() +
|
||||
" Asynchronous connections: " + std::to_string( m_asyncThreads ) +
|
||||
" Synchronous connections: " + std::to_string( m_synchThreads ) );
|
||||
Logger::info( "[DbPool] Opening DatabasePool {0} Asynchronous connections: {1} Synchronous connections: {2}",
|
||||
getDatabaseName(), m_asyncThreads, m_synchThreads );
|
||||
|
||||
uint32_t error = openConnections( IDX_ASYNC, m_asyncThreads );
|
||||
|
||||
|
@ -60,9 +59,8 @@ uint32_t Sapphire::Db::DbWorkerPool< T >::open()
|
|||
|
||||
if( !error )
|
||||
{
|
||||
Logger::info( "[DbPool] DatabasePool " + getDatabaseName() + " opened successfully. " +
|
||||
std::to_string( ( m_connections[ IDX_SYNCH ].size() + m_connections[ IDX_ASYNC ].size() ) ) +
|
||||
" total connections running." );
|
||||
Logger::info( "[DbPool] DatabasePool '{0}' opened successfully. {1} total connections running.",
|
||||
getDatabaseName(), ( m_connections[ IDX_SYNCH ].size() + m_connections[ IDX_ASYNC ].size() ) );
|
||||
}
|
||||
|
||||
return error;
|
||||
|
@ -71,10 +69,10 @@ uint32_t Sapphire::Db::DbWorkerPool< T >::open()
|
|||
template< class T >
|
||||
void Sapphire::Db::DbWorkerPool< T >::close()
|
||||
{
|
||||
Logger::info( "[DbPool] Closing down DatabasePool " + getDatabaseName() );
|
||||
Logger::info( "[DbPool] Closing down DatabasePool {0}", getDatabaseName() );
|
||||
m_connections[ IDX_ASYNC ].clear();
|
||||
m_connections[ IDX_SYNCH ].clear();
|
||||
Logger::info( "[DbPool] All connections on DatabasePool " + getDatabaseName() + "closed." );
|
||||
Logger::info( "[DbPool] All connections on DatabasePool {0} closed.", getDatabaseName() );
|
||||
}
|
||||
|
||||
template< class T >
|
||||
|
|
|
@ -184,13 +184,13 @@ void Sapphire::Db::ZoneDbConnection::doPrepareStatements()
|
|||
CONNECTION_BOTH );
|
||||
|
||||
prepareStatement( ZONE_SEL_SPAWNGROUPS,
|
||||
"SELECT id, bNpcTemplateId, level, maxHp "
|
||||
"SELECT id, bNpcTemplateId, level, maxHp "
|
||||
"FROM spawngroup "
|
||||
"WHERE territoryTypeId = ?",
|
||||
CONNECTION_BOTH );
|
||||
|
||||
prepareStatement( ZONE_SEL_SPAWNPOINTS,
|
||||
"SELECT id, x, y, z, r "
|
||||
"SELECT id, x, y, z, r "
|
||||
"FROM spawnpoint "
|
||||
"WHERE spawnGroupId = ?",
|
||||
CONNECTION_BOTH );
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#include <spdlog/fmt/fmt.h>
|
||||
|
||||
namespace Sapphire
|
||||
{
|
||||
|
||||
|
@ -18,17 +20,54 @@ namespace Sapphire
|
|||
|
||||
static void init( const std::string& logPath );
|
||||
|
||||
// todo: this is a minor increase in build time because of fmtlib, but much less than including spdlog directly
|
||||
|
||||
static void error( const std::string& text );
|
||||
template< typename... Args >
|
||||
static void error( const std::string& fmt, const Args&... args )
|
||||
{
|
||||
error( fmt::format( fmt, args... ) );
|
||||
}
|
||||
|
||||
static void warn( const std::string& text );
|
||||
template< typename... Args >
|
||||
static void warn( const std::string& fmt, const Args&... args )
|
||||
{
|
||||
warn( fmt::format( fmt, args... ) );
|
||||
}
|
||||
|
||||
|
||||
static void info( const std::string& text );
|
||||
template< typename... Args >
|
||||
static void info( const std::string& fmt, const Args&... args )
|
||||
{
|
||||
info( fmt::format( fmt, args... ) );
|
||||
}
|
||||
|
||||
|
||||
static void debug( const std::string& text );
|
||||
template< typename... Args >
|
||||
static void debug( const std::string& fmt, const Args&... args )
|
||||
{
|
||||
debug( fmt::format( fmt, args... ) );
|
||||
}
|
||||
|
||||
|
||||
static void fatal( const std::string& text );
|
||||
template< typename... Args >
|
||||
static void fatal( const std::string& fmt, const Args&... args )
|
||||
{
|
||||
fatal( fmt::format( fmt, args... ) );
|
||||
}
|
||||
|
||||
|
||||
static void trace( const std::string& text );
|
||||
template< typename... Args >
|
||||
static void trace( const std::string& fmt, const Args&... args )
|
||||
{
|
||||
trace( fmt::format( fmt, args... ) );
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -259,8 +259,8 @@ int dumpSpawns()
|
|||
//auto nameStruct = g_exdData.get< Sapphire::Data::BNpcName >( entry.first );
|
||||
auto teri1 = g_exdData.get< Sapphire::Data::TerritoryType >( entry.first );
|
||||
auto teriPlaceName = g_exdData.get< Sapphire::Data::PlaceName >( teri1->placeName );
|
||||
Logger::info( std::to_string( entry.first ) + " - " + teri1->name + " - " + teriPlaceName->name );
|
||||
Logger::info( "Mob Count: " + std::to_string( entry.second.size() ) );
|
||||
Logger::info( "{0} - {1} - {2}", entry.first, teri1->name, teriPlaceName->name );
|
||||
Logger::info( "Mob Count: {0}", entry.second.size() );
|
||||
|
||||
for( auto mob : entry.second )
|
||||
{
|
||||
|
@ -283,9 +283,8 @@ int dumpSpawns()
|
|||
for( auto mobName : lvlToPacket )
|
||||
{
|
||||
auto nameStruct = g_exdData.get< Sapphire::Data::BNpcName >( mobName.second.at(0).bNPCName );
|
||||
Logger::info( "|--> " + nameStruct->singular + "(" + std::to_string( mobName.second.size() ) + ")" );
|
||||
|
||||
Logger::info( "|-> " + std::to_string( entry.first ) );
|
||||
Logger::info( "|--> {0}, ({1})", nameStruct->singular, mobName.second.size() );
|
||||
Logger::info( "|-> {0}", entry.first );
|
||||
|
||||
std::string name1 = delChar( nameStruct->singular, ' ' );
|
||||
name1 = delChar( name1, '\'' );
|
||||
|
|
|
@ -65,11 +65,11 @@ bool Sapphire::World::ServerMgr::loadSettings( int32_t argc, char* argv[] )
|
|||
{
|
||||
auto pConfig = framework()->get< Sapphire::ConfigMgr >();
|
||||
|
||||
Logger::info( "Loading config " + m_configName );
|
||||
Logger::info( "Loading config {0}", m_configName );
|
||||
|
||||
if( !pConfig->loadConfig( m_configName ) )
|
||||
{
|
||||
Logger::fatal( "Error loading config " + m_configName );
|
||||
Logger::fatal( "Error loading config {0}", m_configName );
|
||||
Logger::fatal( "If this is the first time starting the server, we've copied the default one for your editing pleasure." );
|
||||
return false;
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ void Sapphire::World::ServerMgr::run( int32_t argc, char* argv[] )
|
|||
if( !pExdData->init( dataPath ) )
|
||||
{
|
||||
Logger::fatal( "Error setting up generated EXD data. Make sure that DataPath is set correctly in config.ini" );
|
||||
Logger::fatal( "DataPath: " + dataPath );
|
||||
Logger::fatal( "DataPath: {0}", dataPath );
|
||||
return;
|
||||
}
|
||||
framework()->set< Data::ExdDataGenerated >( pExdData );
|
||||
|
@ -192,7 +192,7 @@ void Sapphire::World::ServerMgr::run( int32_t argc, char* argv[] )
|
|||
framework()->set< Manager::EventMgr >( pEventMgr );
|
||||
framework()->set< Manager::ItemMgr >( pItemMgr );
|
||||
|
||||
Logger::info( "World server running on " + m_ip + ":" + std::to_string( m_port ) );
|
||||
Logger::info( "World server running on {0}:{1}", m_ip, m_port );
|
||||
|
||||
mainLoop();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue