1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-27 06:47:45 +00:00

It builds!

This commit is contained in:
Mordred Admin 2018-03-09 10:36:07 +01:00
parent 250b1aef79
commit b441d4ec99
2 changed files with 18 additions and 10 deletions

View file

@ -3,8 +3,9 @@
#include "CharaDbConnection.h" #include "CharaDbConnection.h"
#include "DbWorkerPool.h" #include "DbWorkerPool.h"
#include "Logging/Logger.h" #include "Logging/Logger.h"
#include "Framework.h"
extern Core::Logger g_log; extern Core::Framework g_fw;
Core::Db::DbLoader::DbLoader() Core::Db::DbLoader::DbLoader()
{ {
@ -16,12 +17,14 @@ Core::Db::DbLoader& Core::Db::DbLoader::addDb( Core::Db::DbWorkerPool< T >& pool
m_open.push([this, info, &pool]() -> bool m_open.push([this, info, &pool]() -> bool
{ {
auto pLog = g_fw.get< Logger >();
const uint8_t asyncThreads = info.asyncThreads; const uint8_t asyncThreads = info.asyncThreads;
const uint8_t synchThreads = info.syncThreads; const uint8_t synchThreads = info.syncThreads;
if( asyncThreads < 1 || asyncThreads > 32 ) if( asyncThreads < 1 || asyncThreads > 32 )
{ {
g_log.error( "database: invalid number of worker threads specified. Please pick a value between 1 and 32." ); pLog->error( "database: invalid number of worker threads specified. Please pick a value between 1 and 32." );
return false; return false;
} }
@ -36,7 +39,7 @@ Core::Db::DbLoader& Core::Db::DbLoader::addDb( Core::Db::DbWorkerPool< T >& pool
if( error ) if( error )
{ {
g_log.error( "DatabasePool failed to open." ); pLog->error( "DatabasePool failed to open." );
return false; return false;
} }
} }
@ -50,7 +53,8 @@ Core::Db::DbLoader& Core::Db::DbLoader::addDb( Core::Db::DbWorkerPool< T >& pool
{ {
if( !pool.prepareStatements() ) if( !pool.prepareStatements() )
{ {
g_log.error( "Could not prepare statements of the database, see log for details." ); auto pLog = g_fw.get< Logger >();
pLog->error( "Could not prepare statements of the database, see log for details." );
return false; return false;
} }
return true; return true;
@ -104,5 +108,5 @@ bool Core::Db::DbLoader::process( std::queue< Predicate >& queue )
template template
Core::Db::DbLoader& Core::Db::DbLoader&
Core::Db::DbLoader::addDb< Core::Db::CharaDbConnection >( Core::Db::DbWorkerPool< Core::Db::CharaDbConnection >&, Core::Db::DbLoader::addDb< Core::Db::CharaDbConnection >( Core::Db::DbWorkerPool< Core::Db::CharaDbConnection >&,
const ConnectionInfo& ); const ConnectionInfo& );

View file

@ -6,9 +6,11 @@
#include "Operation.h" #include "Operation.h"
#include "CharaDbConnection.h" #include "CharaDbConnection.h"
#include <boost/make_shared.hpp> #include <boost/make_shared.hpp>
#include "Framework.h"
#include "Logging/Logger.h" #include "Logging/Logger.h"
extern Core::Logger g_log;
extern Core::Framework g_fw;
class PingOperation : public Core::Db::Operation class PingOperation : public Core::Db::Operation
{ {
@ -46,7 +48,8 @@ void Core::Db::DbWorkerPool< T >::setConnectionInfo( const ConnectionInfo& info,
template< class T > template< class T >
uint32_t Core::Db::DbWorkerPool< T >::open() uint32_t Core::Db::DbWorkerPool< T >::open()
{ {
g_log.info( "[DbPool] Opening DatabasePool " + getDatabaseName() + auto pLog = g_fw.get< Logger >();
pLog->info( "[DbPool] Opening DatabasePool " + getDatabaseName() +
" Asynchronous connections: " + std::to_string( m_asyncThreads ) + " Asynchronous connections: " + std::to_string( m_asyncThreads ) +
" Synchronous connections: " + std::to_string( m_synchThreads ) ); " Synchronous connections: " + std::to_string( m_synchThreads ) );
@ -59,7 +62,7 @@ uint32_t Core::Db::DbWorkerPool< T >::open()
if( !error ) if( !error )
{ {
g_log.info( "[DbPool] DatabasePool " + getDatabaseName() + " opened successfully. " + pLog->info( "[DbPool] DatabasePool " + getDatabaseName() + " opened successfully. " +
std::to_string( ( m_connections[IDX_SYNCH].size() + m_connections[IDX_ASYNC].size() ) ) + std::to_string( ( m_connections[IDX_SYNCH].size() + m_connections[IDX_ASYNC].size() ) ) +
" total connections running." ); " total connections running." );
} }
@ -70,10 +73,11 @@ uint32_t Core::Db::DbWorkerPool< T >::open()
template< class T > template< class T >
void Core::Db::DbWorkerPool< T >::close() void Core::Db::DbWorkerPool< T >::close()
{ {
g_log.info("[DbPool] Closing down DatabasePool " + getDatabaseName() ); auto pLog = g_fw.get< Logger >();
pLog->info("[DbPool] Closing down DatabasePool " + getDatabaseName() );
m_connections[IDX_ASYNC].clear(); m_connections[IDX_ASYNC].clear();
m_connections[IDX_SYNCH].clear(); m_connections[IDX_SYNCH].clear();
g_log.info("[DbPool] All connections on DatabasePool " + getDatabaseName() + "closed." ); pLog->info("[DbPool] All connections on DatabasePool " + getDatabaseName() + "closed." );
} }
template< class T > template< class T >