diff options
| author | Machiavelli <none@none> | 2010-08-26 21:50:54 +0200 |
|---|---|---|
| committer | Machiavelli <none@none> | 2010-08-26 21:50:54 +0200 |
| commit | 175fece0737a36690a2f9c283809c5b04b5c2a3c (patch) | |
| tree | 303f8521eca348c13cc650d71f453881586e5854 /src/server/shared/Database | |
| parent | 11de1d43695c289effc5dccb4663d16f927cb657 (diff) | |
Core/Logging:
- Implement sLog.outSQLDriver that will log SQL driver related events (non-content related).
- Queries will now be logged into this file as well instead of normal log file (requires debug build).
- Don“t forget to update your authserver.conf and worldserver.conf
Core/build:
- Fix non-PCH build
--HG--
branch : trunk
Diffstat (limited to 'src/server/shared/Database')
| -rw-r--r-- | src/server/shared/Database/DatabaseWorkerPool.cpp | 23 | ||||
| -rw-r--r-- | src/server/shared/Database/MySQLConnection.cpp | 24 | ||||
| -rw-r--r-- | src/server/shared/Database/Transaction.cpp | 1 |
3 files changed, 25 insertions, 23 deletions
diff --git a/src/server/shared/Database/DatabaseWorkerPool.cpp b/src/server/shared/Database/DatabaseWorkerPool.cpp index 5f6febdac61..a704829545a 100644 --- a/src/server/shared/Database/DatabaseWorkerPool.cpp +++ b/src/server/shared/Database/DatabaseWorkerPool.cpp @@ -17,6 +17,7 @@ */ #include "DatabaseEnv.h" +#include "DatabaseWorker.h" #include "DatabaseWorkerPool.h" #include "MySQLConnection.h" #include "SQLOperation.h" @@ -38,7 +39,7 @@ DatabaseWorkerPool::~DatabaseWorkerPool() bool DatabaseWorkerPool::Open(const std::string& infoString, uint8 num_threads) { - sLog.outDebug("Creating bundled/master MySQL connection."); + sLog.outSQLDriver("Creating bundled/master MySQL connection."); m_bundle_conn = new MySQLConnection(); m_bundle_conn->Open(infoString); ++m_connections; @@ -51,7 +52,7 @@ bool DatabaseWorkerPool::Open(const std::string& infoString, uint8 num_threads) m_async_connections[i] = new MySQLConnection(m_queue); m_async_connections[i]->Open(infoString); ++m_connections; - sLog.outDebug("Async database thread pool opened. Worker thread count: %u", num_threads); + sLog.outSQLDriver("Async database thread pool opened. Worker thread count: %u", num_threads); } m_infoString = infoString; @@ -60,7 +61,7 @@ bool DatabaseWorkerPool::Open(const std::string& infoString, uint8 num_threads) void DatabaseWorkerPool::Close() { - sLog.outStaticDebug("Closing down %u connections on this DatabaseWorkerPool", (uint32)m_connections.value()); + sLog.outSQLDriver("Closing down %u connections on this DatabaseWorkerPool", (uint32)m_connections.value()); /// Shuts down worker threads for this connection pool. m_queue->queue()->deactivate(); @@ -73,14 +74,14 @@ void DatabaseWorkerPool::Close() delete m_bundle_conn; m_bundle_conn = NULL; --m_connections; - sLog.outStaticDebug("Closed bundled connection."); + sLog.outSQLDriver("Closed bundled connection."); //- MySQL::Thread_End() should be called manually from the aborting calling threads - sLog.outStaticDebug("Waiting for %u synchroneous database threads to exit.", (uint32)m_connections.value()); + sLog.outSQLDriver("Waiting for %u synchroneous database threads to exit.", (uint32)m_connections.value()); while (!m_sync_connections.empty()) { } - sLog.outStaticDebug("Synchroneous database threads exited succesfuly."); + sLog.outSQLDriver("Synchroneous database threads exited succesfuly."); } /*! This function creates a new MySQL connection for every MapUpdate thread @@ -96,12 +97,12 @@ void DatabaseWorkerPool::Init_MySQL_Connection() ConnectionMap::const_iterator itr = m_sync_connections.find(ACE_Based::Thread::current()); #ifdef _DEBUG if (itr != m_sync_connections.end()) - sLog.outError("Thread ["UI64FMTD"] already started a MySQL connection", (uint64)ACE_Based::Thread::currentId()); + sLog.outSQLDriver("Thread ["UI64FMTD"] already started a MySQL connection", (uint64)ACE_Based::Thread::currentId()); #endif m_sync_connections[ACE_Based::Thread::current()] = conn; } - sLog.outDebug("Core thread with ID ["UI64FMTD"] initializing MySQL connection.", + sLog.outSQLDriver("Core thread with ID ["UI64FMTD"] initializing MySQL connection.", (uint64)ACE_Based::Thread::currentId()); ++m_connections; @@ -115,7 +116,7 @@ void DatabaseWorkerPool::End_MySQL_Connection() ConnectionMap::iterator itr = m_sync_connections.find(ACE_Based::Thread::current()); #ifdef _DEBUG if (itr == m_sync_connections.end()) - sLog.outError("Thread ["UI64FMTD" already shut down their MySQL connection.", (uint64)ACE_Based::Thread::currentId()); + sLog.outSQLDriver("Thread ["UI64FMTD"] already shut down their MySQL connection.", (uint64)ACE_Based::Thread::currentId()); #endif conn = itr->second; m_sync_connections.erase(itr); @@ -197,12 +198,12 @@ void DatabaseWorkerPool::CommitTransaction(SQLTransaction transaction) #ifdef _DEBUG if (transaction->GetSize() == 0) { - sLog.outError("Transaction contains 0 queries"); + sLog.outSQLDriver("Transaction contains 0 queries. Not executing."); return; } if (transaction->GetSize() == 1) { - sLog.outDetail("Warning: Transaction only holds 1 query, consider removing Transaction context in code."); + sLog.outSQLDriver("Warning: Transaction only holds 1 query, consider removing Transaction context in code."); } #endif Enqueue(new TransactionTask(transaction)); diff --git a/src/server/shared/Database/MySQLConnection.cpp b/src/server/shared/Database/MySQLConnection.cpp index ca06dca14c6..91084af71b8 100644 --- a/src/server/shared/Database/MySQLConnection.cpp +++ b/src/server/shared/Database/MySQLConnection.cpp @@ -120,13 +120,13 @@ bool MySQLConnection::Open(const std::string& infoString) if (m_Mysql) { sLog.outDetail("Connected to MySQL database at %s", host.c_str()); - sLog.outString("MySQL client library: %s", mysql_get_client_info()); - sLog.outString("MySQL server ver: %s ", mysql_get_server_info( m_Mysql)); + sLog.outSQLDriver("MySQL client library: %s", mysql_get_client_info()); + sLog.outSQLDriver("MySQL server ver: %s ", mysql_get_server_info( m_Mysql)); if (!mysql_autocommit(m_Mysql, 1)) - sLog.outDetail("AUTOCOMMIT SUCCESSFULLY SET TO 1"); + sLog.outSQLDriver("AUTOCOMMIT SUCCESSFULLY SET TO 1"); else - sLog.outDetail("AUTOCOMMIT NOT SET TO 1"); + sLog.outSQLDriver("AUTOCOMMIT NOT SET TO 1"); // set connection properties to UTF8 to properly handle locales for different // server configs - core sends data in UTF8, so MySQL must expect UTF8 too @@ -136,9 +136,9 @@ bool MySQLConnection::Open(const std::string& infoString) #if MYSQL_VERSION_ID >= 50003 my_bool my_true = (my_bool)1; if (mysql_options(m_Mysql, MYSQL_OPT_RECONNECT, &my_true)) - sLog.outDetail("Failed to turn on MYSQL_OPT_RECONNECT."); + sLog.outSQLDriver("Failed to turn on MYSQL_OPT_RECONNECT."); else - sLog.outDetail("Successfully turned on MYSQL_OPT_RECONNECT."); + sLog.outSQLDriver("Successfully turned on MYSQL_OPT_RECONNECT."); #else #warning "Your mySQL client lib version does not support reconnecting after a timeout.\nIf this causes you any trouble we advice you to upgrade your mySQL client libs to at least mySQL 5.0.13 to resolve this problem." #endif @@ -166,14 +166,14 @@ bool MySQLConnection::Execute(const char* sql) #endif if (mysql_query(m_Mysql, sql)) { - sLog.outErrorDb("SQL: %s", sql); - sLog.outErrorDb("SQL ERROR: %s", mysql_error(m_Mysql)); + sLog.outSQLDriver("SQL: %s", sql); + sLog.outSQLDriver("SQL ERROR: %s", mysql_error(m_Mysql)); return false; } else { #ifdef TRINITY_DEBUG - sLog.outDebug("[%u ms] SQL: %s", getMSTimeDiff(_s, getMSTime()), sql); + sLog.outSQLDriver("[%u ms] SQL: %s", getMSTimeDiff(_s, getMSTime()), sql); #endif } } @@ -214,14 +214,14 @@ bool MySQLConnection::_Query(const char *sql, MYSQL_RES **pResult, MYSQL_FIELD * #endif if (mysql_query(m_Mysql, sql)) { - sLog.outErrorDb("SQL: %s", sql); - sLog.outErrorDb("query ERROR: %s", mysql_error(m_Mysql)); + sLog.outSQLDriver("SQL: %s", sql); + sLog.outSQLDriver("query ERROR: %s", mysql_error(m_Mysql)); return false; } else { #ifdef TRINITY_DEBUG - sLog.outDebug("[%u ms] SQL: %s", getMSTimeDiff(_s,getMSTime()), sql); + sLog.outSQLDriver("[%u ms] SQL: %s", getMSTimeDiff(_s,getMSTime()), sql); #endif } diff --git a/src/server/shared/Database/Transaction.cpp b/src/server/shared/Database/Transaction.cpp index c535afbc542..d0d8fc1dded 100644 --- a/src/server/shared/Database/Transaction.cpp +++ b/src/server/shared/Database/Transaction.cpp @@ -58,6 +58,7 @@ bool TransactionTask::Execute() sql = queries.front(); if (!m_conn->Execute(sql)) { + sLog.outSQLDriver("[Warning] Transaction aborted. %u queries not executed.", (uint32)queries.size()); free((void*)const_cast<char*>(sql)); queries.pop(); m_conn->RollbackTransaction(); |
