mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Logging: Switch from fmt::sprintf to fmt::format (c++20 standard compatible api)
This commit is contained in:
@@ -39,15 +39,15 @@ DatabaseLoader& DatabaseLoader::AddDatabase(DatabaseWorkerPool<T>& pool, std::st
|
||||
std::string const dbString = sConfigMgr->GetStringDefault(name + "DatabaseInfo", "");
|
||||
if (dbString.empty())
|
||||
{
|
||||
TC_LOG_ERROR(_logger, "Database %s not specified in configuration file!", name.c_str());
|
||||
TC_LOG_ERROR(_logger, "Database {} not specified in configuration file!", name);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8 const asyncThreads = uint8(sConfigMgr->GetIntDefault(name + "Database.WorkerThreads", 1));
|
||||
if (asyncThreads < 1 || asyncThreads > 32)
|
||||
{
|
||||
TC_LOG_ERROR(_logger, "%s database: invalid number of worker threads specified. "
|
||||
"Please pick a value between 1 and 32.", name.c_str());
|
||||
TC_LOG_ERROR(_logger, "{} database: invalid number of worker threads specified. "
|
||||
"Please pick a value between 1 and 32.", name);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -67,8 +67,8 @@ DatabaseLoader& DatabaseLoader::AddDatabase(DatabaseWorkerPool<T>& pool, std::st
|
||||
// If the error wasn't handled quit
|
||||
if (error)
|
||||
{
|
||||
TC_LOG_ERROR("sql.driver", "\nDatabasePool %s NOT opened. There were errors opening the MySQL connections. Check your SQLDriverLogFile "
|
||||
"for specific errors. Read wiki at https://www.trinitycore.info/display/tc/TrinityCore+Home", name.c_str());
|
||||
TC_LOG_ERROR("sql.driver", "\nDatabasePool {} NOT opened. There were errors opening the MySQL connections. Check your SQLDriverLogFile "
|
||||
"for specific errors. Read wiki at https://www.trinitycore.info/display/tc/TrinityCore+Home", name);
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -88,7 +88,7 @@ DatabaseLoader& DatabaseLoader::AddDatabase(DatabaseWorkerPool<T>& pool, std::st
|
||||
{
|
||||
if (!DBUpdater<T>::Populate(pool))
|
||||
{
|
||||
TC_LOG_ERROR(_logger, "Could not populate the %s database, see log for details.", name.c_str());
|
||||
TC_LOG_ERROR(_logger, "Could not populate the {} database, see log for details.", name);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -98,7 +98,7 @@ DatabaseLoader& DatabaseLoader::AddDatabase(DatabaseWorkerPool<T>& pool, std::st
|
||||
{
|
||||
if (!DBUpdater<T>::Update(pool))
|
||||
{
|
||||
TC_LOG_ERROR(_logger, "Could not update the %s database, see log for details.", name.c_str());
|
||||
TC_LOG_ERROR(_logger, "Could not update the {} database, see log for details.", name);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -109,7 +109,7 @@ DatabaseLoader& DatabaseLoader::AddDatabase(DatabaseWorkerPool<T>& pool, std::st
|
||||
{
|
||||
if (!pool.PrepareStatements())
|
||||
{
|
||||
TC_LOG_ERROR(_logger, "Could not prepare statements of the %s database, see log for details.", name.c_str());
|
||||
TC_LOG_ERROR(_logger, "Could not prepare statements of the {} database, see log for details.", name);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -96,8 +96,8 @@ uint32 DatabaseWorkerPool<T>::Open()
|
||||
{
|
||||
WPFatal(_connectionInfo.get(), "Connection info was not set!");
|
||||
|
||||
TC_LOG_INFO("sql.driver", "Opening DatabasePool '%s'. "
|
||||
"Asynchronous connections: %u, synchronous connections: %u.",
|
||||
TC_LOG_INFO("sql.driver", "Opening DatabasePool '{}'. "
|
||||
"Asynchronous connections: {}, synchronous connections: {}.",
|
||||
GetDatabaseName(), _async_threads, _synch_threads);
|
||||
|
||||
uint32 error = OpenConnections(IDX_ASYNC, _async_threads);
|
||||
@@ -109,7 +109,7 @@ uint32 DatabaseWorkerPool<T>::Open()
|
||||
|
||||
if (!error)
|
||||
{
|
||||
TC_LOG_INFO("sql.driver", "DatabasePool '%s' opened successfully. " SZFMTD
|
||||
TC_LOG_INFO("sql.driver", "DatabasePool '{}' opened successfully. " SZFMTD
|
||||
" total connections running.", GetDatabaseName(),
|
||||
(_connections[IDX_SYNCH].size() + _connections[IDX_ASYNC].size()));
|
||||
}
|
||||
@@ -120,12 +120,12 @@ uint32 DatabaseWorkerPool<T>::Open()
|
||||
template <class T>
|
||||
void DatabaseWorkerPool<T>::Close()
|
||||
{
|
||||
TC_LOG_INFO("sql.driver", "Closing down DatabasePool '%s'.", GetDatabaseName());
|
||||
TC_LOG_INFO("sql.driver", "Closing down DatabasePool '{}'.", GetDatabaseName());
|
||||
|
||||
//! Closes the actualy MySQL connection.
|
||||
_connections[IDX_ASYNC].clear();
|
||||
|
||||
TC_LOG_INFO("sql.driver", "Asynchronous connections on DatabasePool '%s' terminated. "
|
||||
TC_LOG_INFO("sql.driver", "Asynchronous connections on DatabasePool '{}' terminated. "
|
||||
"Proceeding with synchronous connections.",
|
||||
GetDatabaseName());
|
||||
|
||||
@@ -135,7 +135,7 @@ void DatabaseWorkerPool<T>::Close()
|
||||
//! meaning there can be no concurrent access at this point.
|
||||
_connections[IDX_SYNCH].clear();
|
||||
|
||||
TC_LOG_INFO("sql.driver", "All connections on DatabasePool '%s' closed.", GetDatabaseName());
|
||||
TC_LOG_INFO("sql.driver", "All connections on DatabasePool '{}' closed.", GetDatabaseName());
|
||||
}
|
||||
|
||||
template <class T>
|
||||
@@ -403,9 +403,9 @@ uint32 DatabaseWorkerPool<T>::OpenConnections(InternalIndex type, uint8 numConne
|
||||
#endif
|
||||
{
|
||||
#ifndef LIBMARIADB
|
||||
TC_LOG_ERROR("sql.driver", "TrinityCore does not support MySQL versions below " MIN_MYSQL_SERVER_VERSION_STRING " (found id %u, need id >= %u), please update your MySQL server", connection->GetServerVersion(), MIN_MYSQL_SERVER_VERSION);
|
||||
TC_LOG_ERROR("sql.driver", "TrinityCore does not support MySQL versions below " MIN_MYSQL_SERVER_VERSION_STRING " (found id {}, need id >= {}), please update your MySQL server", connection->GetServerVersion(), MIN_MYSQL_SERVER_VERSION);
|
||||
#else
|
||||
TC_LOG_ERROR("sql.driver", "TrinityCore does not support MariaDB versions below " MIN_MARIADB_SERVER_VERSION_STRING " (found id %u, need id >= %u), please update your MySQL server", connection->GetServerVersion(), MIN_MARIADB_SERVER_VERSION);
|
||||
TC_LOG_ERROR("sql.driver", "TrinityCore does not support MariaDB versions below " MIN_MARIADB_SERVER_VERSION_STRING " (found id {}, need id >= {}), please update your MySQL server", connection->GetServerVersion(), MIN_MARIADB_SERVER_VERSION);
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
@@ -449,7 +449,7 @@ T* DatabaseWorkerPool<T>::GetFreeConnection()
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss << boost::stacktrace::stacktrace();
|
||||
TC_LOG_WARN("sql.performances", "Sync query at:\n%s", ss.str().c_str());
|
||||
TC_LOG_WARN("sql.performances", "Sync query at:\n{}", ss.str());
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -477,7 +477,7 @@ char const* DatabaseWorkerPool<T>::GetDatabaseName() const
|
||||
template <class T>
|
||||
void DatabaseWorkerPool<T>::Execute(char const* sql)
|
||||
{
|
||||
if (Trinity::IsFormatEmptyOrNull(sql))
|
||||
if (!sql)
|
||||
return;
|
||||
|
||||
BasicStatementTask* task = new BasicStatementTask(sql);
|
||||
@@ -494,7 +494,7 @@ void DatabaseWorkerPool<T>::Execute(PreparedStatement<T>* stmt)
|
||||
template <class T>
|
||||
void DatabaseWorkerPool<T>::DirectExecute(char const* sql)
|
||||
{
|
||||
if (Trinity::IsFormatEmptyOrNull(sql))
|
||||
if (!sql)
|
||||
return;
|
||||
|
||||
T* connection = GetFreeConnection();
|
||||
|
||||
@@ -73,7 +73,7 @@ class DatabaseWorkerPool
|
||||
//! Enqueues a one-way SQL operation in string format -with variable args- that will be executed asynchronously.
|
||||
//! This method should only be used for queries that are only executed once, e.g during startup.
|
||||
template<typename... Args>
|
||||
void PExecute(std::string_view sql, Args&&... args)
|
||||
void PExecute(Trinity::FormatString<Args...> sql, Args&&... args)
|
||||
{
|
||||
if (Trinity::IsFormatEmptyOrNull(sql))
|
||||
return;
|
||||
@@ -96,7 +96,7 @@ class DatabaseWorkerPool
|
||||
//! Directly executes a one-way SQL operation in string format -with variable args-, that will block the calling thread until finished.
|
||||
//! This method should only be used for queries that are only executed once, e.g during startup.
|
||||
template<typename... Args>
|
||||
void DirectPExecute(std::string_view sql, Args&&... args)
|
||||
void DirectPExecute(Trinity::FormatString<Args...> sql, Args&&... args)
|
||||
{
|
||||
if (Trinity::IsFormatEmptyOrNull(sql))
|
||||
return;
|
||||
@@ -119,7 +119,7 @@ class DatabaseWorkerPool
|
||||
//! Directly executes an SQL query in string format -with variable args- that will block the calling thread until finished.
|
||||
//! Returns reference counted auto pointer, no need for manual memory management in upper level code.
|
||||
template<typename... Args>
|
||||
QueryResult PQuery(std::string_view sql, T* conn, Args&&... args)
|
||||
QueryResult PQuery(Trinity::FormatString<Args...> sql, T* conn, Args&&... args)
|
||||
{
|
||||
if (Trinity::IsFormatEmptyOrNull(sql))
|
||||
return QueryResult(nullptr);
|
||||
@@ -130,7 +130,7 @@ class DatabaseWorkerPool
|
||||
//! Directly executes an SQL query in string format -with variable args- that will block the calling thread until finished.
|
||||
//! Returns reference counted auto pointer, no need for manual memory management in upper level code.
|
||||
template<typename... Args>
|
||||
QueryResult PQuery(std::string_view sql, Args&&... args)
|
||||
QueryResult PQuery(Trinity::FormatString<Args...> sql, Args&&... args)
|
||||
{
|
||||
if (Trinity::IsFormatEmptyOrNull(sql))
|
||||
return QueryResult(nullptr);
|
||||
|
||||
@@ -299,7 +299,7 @@ bool Field::IsNumeric() const
|
||||
|
||||
void Field::LogWrongType(char const* getter) const
|
||||
{
|
||||
TC_LOG_WARN("sql.sql", "Warning: %s on %s field %s.%s (%s.%s) at index %u.",
|
||||
TC_LOG_WARN("sql.sql", "Warning: {} on {} field {}.{} ({}.{}) at index {}.",
|
||||
getter, meta->TypeName, meta->TableAlias, meta->Alias, meta->TableName, meta->Name, meta->Index);
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ uint32 MySQLConnection::Open()
|
||||
mysqlInit = mysql_init(nullptr);
|
||||
if (!mysqlInit)
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Could not initialize Mysql connection to database `%s`", m_connectionInfo.database.c_str());
|
||||
TC_LOG_ERROR("sql.sql", "Could not initialize Mysql connection to database `{}`", m_connectionInfo.database);
|
||||
return CR_UNKNOWN_ERROR;
|
||||
}
|
||||
|
||||
@@ -156,14 +156,14 @@ uint32 MySQLConnection::Open()
|
||||
{
|
||||
if (!m_reconnecting)
|
||||
{
|
||||
TC_LOG_INFO("sql.sql", "MySQL client library: %s", mysql_get_client_info());
|
||||
TC_LOG_INFO("sql.sql", "MySQL server ver: %s ", mysql_get_server_info(m_Mysql));
|
||||
TC_LOG_INFO("sql.sql", "MySQL client library: {}", mysql_get_client_info());
|
||||
TC_LOG_INFO("sql.sql", "MySQL server ver: {} ", mysql_get_server_info(m_Mysql));
|
||||
// MySQL version above 5.1 IS required in both client and server and there is no known issue with different versions above 5.1
|
||||
// if (mysql_get_server_version(m_Mysql) != mysql_get_client_version())
|
||||
// TC_LOG_INFO("sql.sql", "[WARNING] MySQL client/server version mismatch; may conflict with behaviour of prepared statements.");
|
||||
}
|
||||
|
||||
TC_LOG_INFO("sql.sql", "Connected to MySQL database at %s", m_connectionInfo.host.c_str());
|
||||
TC_LOG_INFO("sql.sql", "Connected to MySQL database at {}", m_connectionInfo.host);
|
||||
mysql_autocommit(m_Mysql, 1);
|
||||
|
||||
// set connection properties to UTF8 to properly handle locales for different
|
||||
@@ -173,7 +173,7 @@ uint32 MySQLConnection::Open()
|
||||
}
|
||||
else
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Could not connect to MySQL database at %s: %s", m_connectionInfo.host.c_str(), mysql_error(mysqlInit));
|
||||
TC_LOG_ERROR("sql.sql", "Could not connect to MySQL database at {}: {}", m_connectionInfo.host, mysql_error(mysqlInit));
|
||||
uint32 errorCode = mysql_errno(mysqlInit);
|
||||
mysql_close(mysqlInit);
|
||||
return errorCode;
|
||||
@@ -198,8 +198,8 @@ bool MySQLConnection::Execute(char const* sql)
|
||||
{
|
||||
uint32 lErrno = mysql_errno(m_Mysql);
|
||||
|
||||
TC_LOG_INFO("sql.sql", "SQL: %s", sql);
|
||||
TC_LOG_ERROR("sql.sql", "[%u] %s", lErrno, mysql_error(m_Mysql));
|
||||
TC_LOG_INFO("sql.sql", "SQL: {}", sql);
|
||||
TC_LOG_ERROR("sql.sql", "[{}] {}", lErrno, mysql_error(m_Mysql));
|
||||
|
||||
if (_HandleMySQLErrno(lErrno)) // If it returns true, an error was handled successfully (i.e. reconnection)
|
||||
return Execute(sql); // Try again
|
||||
@@ -207,7 +207,7 @@ bool MySQLConnection::Execute(char const* sql)
|
||||
return false;
|
||||
}
|
||||
else
|
||||
TC_LOG_DEBUG("sql.sql", "[%u ms] SQL: %s", getMSTimeDiff(_s, getMSTime()), sql);
|
||||
TC_LOG_DEBUG("sql.sql", "[{} ms] SQL: {}", getMSTimeDiff(_s, getMSTime()), sql);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -233,7 +233,7 @@ bool MySQLConnection::Execute(PreparedStatementBase* stmt)
|
||||
if (mysql_stmt_bind_param(msql_STMT, msql_BIND))
|
||||
{
|
||||
uint32 lErrno = mysql_errno(m_Mysql);
|
||||
TC_LOG_ERROR("sql.sql", "SQL(p): %s\n [ERROR]: [%u] %s", m_mStmt->getQueryString().c_str(), lErrno, mysql_stmt_error(msql_STMT));
|
||||
TC_LOG_ERROR("sql.sql", "SQL(p): {}\n [ERROR]: [{}] {}", m_mStmt->getQueryString(), lErrno, mysql_stmt_error(msql_STMT));
|
||||
|
||||
if (_HandleMySQLErrno(lErrno)) // If it returns true, an error was handled successfully (i.e. reconnection)
|
||||
return Execute(stmt); // Try again
|
||||
@@ -245,7 +245,7 @@ bool MySQLConnection::Execute(PreparedStatementBase* stmt)
|
||||
if (mysql_stmt_execute(msql_STMT))
|
||||
{
|
||||
uint32 lErrno = mysql_errno(m_Mysql);
|
||||
TC_LOG_ERROR("sql.sql", "SQL(p): %s\n [ERROR]: [%u] %s", m_mStmt->getQueryString().c_str(), lErrno, mysql_stmt_error(msql_STMT));
|
||||
TC_LOG_ERROR("sql.sql", "SQL(p): {}\n [ERROR]: [{}] {}", m_mStmt->getQueryString(), lErrno, mysql_stmt_error(msql_STMT));
|
||||
|
||||
if (_HandleMySQLErrno(lErrno)) // If it returns true, an error was handled successfully (i.e. reconnection)
|
||||
return Execute(stmt); // Try again
|
||||
@@ -254,7 +254,7 @@ bool MySQLConnection::Execute(PreparedStatementBase* stmt)
|
||||
return false;
|
||||
}
|
||||
|
||||
TC_LOG_DEBUG("sql.sql", "[%u ms] SQL(p): %s", getMSTimeDiff(_s, getMSTime()), m_mStmt->getQueryString().c_str());
|
||||
TC_LOG_DEBUG("sql.sql", "[{} ms] SQL(p): {}", getMSTimeDiff(_s, getMSTime()), m_mStmt->getQueryString());
|
||||
|
||||
m_mStmt->ClearParameters();
|
||||
return true;
|
||||
@@ -281,7 +281,7 @@ bool MySQLConnection::_Query(PreparedStatementBase* stmt, MySQLPreparedStatement
|
||||
if (mysql_stmt_bind_param(msql_STMT, msql_BIND))
|
||||
{
|
||||
uint32 lErrno = mysql_errno(m_Mysql);
|
||||
TC_LOG_ERROR("sql.sql", "SQL(p): %s\n [ERROR]: [%u] %s", m_mStmt->getQueryString().c_str(), lErrno, mysql_stmt_error(msql_STMT));
|
||||
TC_LOG_ERROR("sql.sql", "SQL(p): {}\n [ERROR]: [{}] {}", m_mStmt->getQueryString(), lErrno, mysql_stmt_error(msql_STMT));
|
||||
|
||||
if (_HandleMySQLErrno(lErrno)) // If it returns true, an error was handled successfully (i.e. reconnection)
|
||||
return _Query(stmt, mysqlStmt, pResult, pRowCount, pFieldCount); // Try again
|
||||
@@ -293,8 +293,8 @@ bool MySQLConnection::_Query(PreparedStatementBase* stmt, MySQLPreparedStatement
|
||||
if (mysql_stmt_execute(msql_STMT))
|
||||
{
|
||||
uint32 lErrno = mysql_errno(m_Mysql);
|
||||
TC_LOG_ERROR("sql.sql", "SQL(p): %s\n [ERROR]: [%u] %s",
|
||||
m_mStmt->getQueryString().c_str(), lErrno, mysql_stmt_error(msql_STMT));
|
||||
TC_LOG_ERROR("sql.sql", "SQL(p): {}\n [ERROR]: [{}] {}",
|
||||
m_mStmt->getQueryString(), lErrno, mysql_stmt_error(msql_STMT));
|
||||
|
||||
if (_HandleMySQLErrno(lErrno)) // If it returns true, an error was handled successfully (i.e. reconnection)
|
||||
return _Query(stmt, mysqlStmt, pResult, pRowCount, pFieldCount); // Try again
|
||||
@@ -303,7 +303,7 @@ bool MySQLConnection::_Query(PreparedStatementBase* stmt, MySQLPreparedStatement
|
||||
return false;
|
||||
}
|
||||
|
||||
TC_LOG_DEBUG("sql.sql", "[%u ms] SQL(p): %s", getMSTimeDiff(_s, getMSTime()), m_mStmt->getQueryString().c_str());
|
||||
TC_LOG_DEBUG("sql.sql", "[{} ms] SQL(p): {}", getMSTimeDiff(_s, getMSTime()), m_mStmt->getQueryString());
|
||||
|
||||
m_mStmt->ClearParameters();
|
||||
|
||||
@@ -341,8 +341,8 @@ bool MySQLConnection::_Query(const char* sql, MySQLResult** pResult, MySQLField*
|
||||
if (mysql_query(m_Mysql, sql))
|
||||
{
|
||||
uint32 lErrno = mysql_errno(m_Mysql);
|
||||
TC_LOG_INFO("sql.sql", "SQL: %s", sql);
|
||||
TC_LOG_ERROR("sql.sql", "[%u] %s", lErrno, mysql_error(m_Mysql));
|
||||
TC_LOG_INFO("sql.sql", "SQL: {}", sql);
|
||||
TC_LOG_ERROR("sql.sql", "[{}] {}", lErrno, mysql_error(m_Mysql));
|
||||
|
||||
if (_HandleMySQLErrno(lErrno)) // If it returns true, an error was handled successfully (i.e. reconnection)
|
||||
return _Query(sql, pResult, pFields, pRowCount, pFieldCount); // We try again
|
||||
@@ -350,7 +350,7 @@ bool MySQLConnection::_Query(const char* sql, MySQLResult** pResult, MySQLField*
|
||||
return false;
|
||||
}
|
||||
else
|
||||
TC_LOG_DEBUG("sql.sql", "[%u ms] SQL: %s", getMSTimeDiff(_s, getMSTime()), sql);
|
||||
TC_LOG_DEBUG("sql.sql", "[{} ms] SQL: {}", getMSTimeDiff(_s, getMSTime()), sql);
|
||||
|
||||
*pResult = reinterpret_cast<MySQLResult*>(mysql_store_result(m_Mysql));
|
||||
*pRowCount = mysql_affected_rows(m_Mysql);
|
||||
@@ -405,7 +405,7 @@ int MySQLConnection::ExecuteTransaction(std::shared_ptr<TransactionBase> transac
|
||||
ASSERT(stmt);
|
||||
if (!Execute(stmt))
|
||||
{
|
||||
TC_LOG_WARN("sql.sql", "Transaction aborted. %u queries not executed.", (uint32)queries.size());
|
||||
TC_LOG_WARN("sql.sql", "Transaction aborted. {} queries not executed.", (uint32)queries.size());
|
||||
int errorCode = GetLastError();
|
||||
RollbackTransaction();
|
||||
return errorCode;
|
||||
@@ -418,7 +418,7 @@ int MySQLConnection::ExecuteTransaction(std::shared_ptr<TransactionBase> transac
|
||||
ASSERT(sql);
|
||||
if (!Execute(sql))
|
||||
{
|
||||
TC_LOG_WARN("sql.sql", "Transaction aborted. %u queries not executed.", (uint32)queries.size());
|
||||
TC_LOG_WARN("sql.sql", "Transaction aborted. {} queries not executed.", (uint32)queries.size());
|
||||
int errorCode = GetLastError();
|
||||
RollbackTransaction();
|
||||
return errorCode;
|
||||
@@ -473,8 +473,8 @@ MySQLPreparedStatement* MySQLConnection::GetPreparedStatement(uint32 index)
|
||||
index, m_stmts.size(), m_connectionInfo.database.c_str(), (m_connectionFlags & CONNECTION_ASYNC) ? "asynchronous" : "synchronous");
|
||||
MySQLPreparedStatement* ret = m_stmts[index].get();
|
||||
if (!ret)
|
||||
TC_LOG_ERROR("sql.sql", "Could not fetch prepared statement %u on database `%s`, connection type: %s.",
|
||||
index, m_connectionInfo.database.c_str(), (m_connectionFlags & CONNECTION_ASYNC) ? "asynchronous" : "synchronous");
|
||||
TC_LOG_ERROR("sql.sql", "Could not fetch prepared statement {} on database `{}`, connection type: {}.",
|
||||
index, m_connectionInfo.database, (m_connectionFlags & CONNECTION_ASYNC) ? "asynchronous" : "synchronous");
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -493,16 +493,16 @@ void MySQLConnection::PrepareStatement(uint32 index, std::string const& sql, Con
|
||||
MYSQL_STMT* stmt = mysql_stmt_init(m_Mysql);
|
||||
if (!stmt)
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "In mysql_stmt_init() id: %u, sql: \"%s\"", index, sql.c_str());
|
||||
TC_LOG_ERROR("sql.sql", "%s", mysql_error(m_Mysql));
|
||||
TC_LOG_ERROR("sql.sql", "In mysql_stmt_init() id: {}, sql: \"{}\"", index, sql);
|
||||
TC_LOG_ERROR("sql.sql", "{}", mysql_error(m_Mysql));
|
||||
m_prepareError = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mysql_stmt_prepare(stmt, sql.c_str(), static_cast<unsigned long>(sql.size())))
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "In mysql_stmt_prepare() id: %u, sql: \"%s\"", index, sql.c_str());
|
||||
TC_LOG_ERROR("sql.sql", "%s", mysql_stmt_error(stmt));
|
||||
TC_LOG_ERROR("sql.sql", "In mysql_stmt_prepare() id: {}, sql: \"{}\"", index, sql);
|
||||
TC_LOG_ERROR("sql.sql", "{}", mysql_stmt_error(stmt));
|
||||
mysql_stmt_close(stmt);
|
||||
m_prepareError = true;
|
||||
}
|
||||
@@ -562,8 +562,8 @@ bool MySQLConnection::_HandleMySQLErrno(uint32 errNo, uint8 attempts /*= 5*/)
|
||||
std::abort();
|
||||
}
|
||||
|
||||
TC_LOG_INFO("sql.sql", "Successfully reconnected to %s @%s:%s (%s).",
|
||||
m_connectionInfo.database.c_str(), m_connectionInfo.host.c_str(), m_connectionInfo.port_or_socket.c_str(),
|
||||
TC_LOG_INFO("sql.sql", "Successfully reconnected to {} @{}:{} ({}).",
|
||||
m_connectionInfo.database, m_connectionInfo.host, m_connectionInfo.port_or_socket,
|
||||
(m_connectionFlags & CONNECTION_ASYNC) ? "asynchronous" : "synchronous");
|
||||
|
||||
m_reconnecting = false;
|
||||
@@ -610,7 +610,7 @@ bool MySQLConnection::_HandleMySQLErrno(uint32 errNo, uint8 attempts /*= 5*/)
|
||||
std::abort();
|
||||
return false;
|
||||
default:
|
||||
TC_LOG_ERROR("sql.sql", "Unhandled MySQL errno %u. Unexpected behaviour possible.", errNo);
|
||||
TC_LOG_ERROR("sql.sql", "Unhandled MySQL errno {}. Unexpected behaviour possible.", errNo);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ void MySQLPreparedStatement::BindParameters(PreparedStatementBase* stmt)
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
if (pos < m_paramCount)
|
||||
TC_LOG_WARN("sql.sql", "[WARNING]: BindParameters() for statement %u did not bind all allocated parameters", stmt->GetIndex());
|
||||
TC_LOG_WARN("sql.sql", "[WARNING]: BindParameters() for statement {} did not bind all allocated parameters", stmt->GetIndex());
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ void MySQLPreparedStatement::ClearParameters()
|
||||
|
||||
static bool ParamenterIndexAssertFail(uint32 stmtIndex, uint8 index, uint32 paramCount)
|
||||
{
|
||||
TC_LOG_ERROR("sql.driver", "Attempted to bind parameter %u%s on a PreparedStatement %u (statement has only %u parameters)", uint32(index) + 1, (index == 1 ? "st" : (index == 2 ? "nd" : (index == 3 ? "rd" : "nd"))), stmtIndex, paramCount);
|
||||
TC_LOG_ERROR("sql.driver", "Attempted to bind parameter {}{} on a PreparedStatement {} (statement has only {} parameters)", uint32(index) + 1, (index == 1 ? "st" : (index == 2 ? "nd" : (index == 3 ? "rd" : "nd"))), stmtIndex, paramCount);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ void MySQLPreparedStatement::AssertValidIndex(uint8 index)
|
||||
ASSERT(index < m_paramCount || ParamenterIndexAssertFail(m_stmt->GetIndex(), index, m_paramCount));
|
||||
|
||||
if (m_paramsSet[index])
|
||||
TC_LOG_ERROR("sql.sql", "[ERROR] Prepared Statement (id: %u) trying to bind value on already bound index (%u).", m_stmt->GetIndex(), index);
|
||||
TC_LOG_ERROR("sql.sql", "[ERROR] Prepared Statement (id: {}) trying to bind value on already bound index ({}).", m_stmt->GetIndex(), index);
|
||||
}
|
||||
|
||||
void MySQLPreparedStatement::SetParameter(uint8 index, std::nullptr_t)
|
||||
|
||||
@@ -154,7 +154,7 @@ bool PreparedStatementTask::Execute()
|
||||
template<typename T>
|
||||
std::string PreparedStatementData::ToString(T value)
|
||||
{
|
||||
return fmt::format("{}", value);
|
||||
return Trinity::StringFormat("{}", value);
|
||||
}
|
||||
|
||||
std::string PreparedStatementData::ToString(bool value)
|
||||
@@ -184,7 +184,7 @@ template std::string PreparedStatementData::ToString<double>(double);
|
||||
|
||||
std::string PreparedStatementData::ToString(std::string const& value)
|
||||
{
|
||||
return fmt::format("'{}'", value);
|
||||
return Trinity::StringFormat("'{}'", value);
|
||||
}
|
||||
|
||||
std::string PreparedStatementData::ToString(std::vector<uint8> const& /*value*/)
|
||||
|
||||
@@ -26,7 +26,7 @@ bool SQLQueryHolderBase::SetPreparedQueryImpl(size_t index, PreparedStatementBas
|
||||
{
|
||||
if (m_queries.size() <= index)
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Query index (%u) out of range (size: %u) for prepared statement", uint32(index), (uint32)m_queries.size());
|
||||
TC_LOG_ERROR("sql.sql", "Query index ({}) out of range (size: {}) for prepared statement", uint32(index), (uint32)m_queries.size());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ static uint32 SizeForType(MYSQL_FIELD* field)
|
||||
MYSQL_TYPE_SET:
|
||||
*/
|
||||
default:
|
||||
TC_LOG_WARN("sql.sql", "SQL::SizeForType(): invalid field type %u", uint32(field->type));
|
||||
TC_LOG_WARN("sql.sql", "SQL::SizeForType(): invalid field type {}", uint32(field->type));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -112,7 +112,7 @@ DatabaseFieldTypes MysqlTypeToFieldType(enum_field_types type)
|
||||
case MYSQL_TYPE_VAR_STRING:
|
||||
return DatabaseFieldTypes::Binary;
|
||||
default:
|
||||
TC_LOG_WARN("sql.sql", "MysqlTypeToFieldType(): invalid field type %u", uint32(type));
|
||||
TC_LOG_WARN("sql.sql", "MysqlTypeToFieldType(): invalid field type {}", uint32(type));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@ m_metadataResult(result)
|
||||
//- This is where we store the (entire) resultset
|
||||
if (mysql_stmt_store_result(m_stmt))
|
||||
{
|
||||
TC_LOG_WARN("sql.sql", "%s:mysql_stmt_store_result, cannot bind result from MySQL server. Error: %s", __FUNCTION__, mysql_stmt_error(m_stmt));
|
||||
TC_LOG_WARN("sql.sql", "{}:mysql_stmt_store_result, cannot bind result from MySQL server. Error: {}", __FUNCTION__, mysql_stmt_error(m_stmt));
|
||||
delete[] m_rBind;
|
||||
delete[] m_isNull;
|
||||
delete[] m_length;
|
||||
@@ -250,7 +250,7 @@ m_metadataResult(result)
|
||||
//- This is where we bind the bind the buffer to the statement
|
||||
if (mysql_stmt_bind_result(m_stmt, m_rBind))
|
||||
{
|
||||
TC_LOG_WARN("sql.sql", "%s:mysql_stmt_bind_result, cannot bind result from MySQL server. Error: %s", __FUNCTION__, mysql_stmt_error(m_stmt));
|
||||
TC_LOG_WARN("sql.sql", "{}:mysql_stmt_bind_result, cannot bind result from MySQL server. Error: {}", __FUNCTION__, mysql_stmt_error(m_stmt));
|
||||
mysql_stmt_free_result(m_stmt);
|
||||
CleanUp();
|
||||
delete[] m_isNull;
|
||||
@@ -339,7 +339,7 @@ bool ResultSet::NextRow()
|
||||
unsigned long* lengths = mysql_fetch_lengths(_result);
|
||||
if (!lengths)
|
||||
{
|
||||
TC_LOG_WARN("sql.sql", "%s:mysql_fetch_lengths, cannot retrieve value lengths. Error %s.", __FUNCTION__, mysql_error(_result->handle));
|
||||
TC_LOG_WARN("sql.sql", "{}:mysql_fetch_lengths, cannot retrieve value lengths. Error {}.", __FUNCTION__, mysql_error(_result->handle));
|
||||
CleanUp();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -94,10 +94,10 @@ bool TransactionTask::Execute()
|
||||
if (!TryExecute())
|
||||
return true;
|
||||
|
||||
TC_LOG_WARN("sql.sql", "Deadlocked SQL Transaction, retrying. Loop timer: %u ms, Thread Id: %s", loopDuration, threadId.c_str());
|
||||
TC_LOG_WARN("sql.sql", "Deadlocked SQL Transaction, retrying. Loop timer: {} ms, Thread Id: {}", loopDuration, threadId);
|
||||
}
|
||||
|
||||
TC_LOG_ERROR("sql.sql", "Fatal deadlocked SQL Transaction, it will not be retried anymore. Thread Id: %s", threadId.c_str());
|
||||
TC_LOG_ERROR("sql.sql", "Fatal deadlocked SQL Transaction, it will not be retried anymore. Thread Id: {}", threadId);
|
||||
}
|
||||
|
||||
// Clean up now.
|
||||
@@ -145,10 +145,10 @@ bool TransactionWithResultTask::Execute()
|
||||
return true;
|
||||
}
|
||||
|
||||
TC_LOG_WARN("sql.sql", "Deadlocked SQL Transaction, retrying. Loop timer: %u ms, Thread Id: %s", loopDuration, threadId.c_str());
|
||||
TC_LOG_WARN("sql.sql", "Deadlocked SQL Transaction, retrying. Loop timer: {} ms, Thread Id: {}", loopDuration, threadId);
|
||||
}
|
||||
|
||||
TC_LOG_ERROR("sql.sql", "Fatal deadlocked SQL Transaction, it will not be retried anymore. Thread Id: %s", threadId.c_str());
|
||||
TC_LOG_ERROR("sql.sql", "Fatal deadlocked SQL Transaction, it will not be retried anymore. Thread Id: {}", threadId);
|
||||
}
|
||||
|
||||
// Clean up now.
|
||||
|
||||
@@ -41,7 +41,7 @@ class TC_DATABASE_API TransactionBase
|
||||
|
||||
void Append(char const* sql);
|
||||
template<typename... Args>
|
||||
void PAppend(std::string_view sql, Args&&... args)
|
||||
void PAppend(Trinity::FormatString<Args...> sql, Args&&... args)
|
||||
{
|
||||
Append(Trinity::StringFormat(sql, std::forward<Args>(args)...).c_str());
|
||||
}
|
||||
|
||||
@@ -50,8 +50,8 @@ bool DBUpdaterUtil::CheckExecutable()
|
||||
return true;
|
||||
}
|
||||
|
||||
TC_LOG_FATAL("sql.updates", "Didn't find any executable MySQL binary at \'%s\' or in path, correct the path in the *.conf (\"MySQLExecutable\").",
|
||||
absolute(exe).generic_string().c_str());
|
||||
TC_LOG_FATAL("sql.updates", "Didn't find any executable MySQL binary at \'{}\' or in path, correct the path in the *.conf (\"MySQLExecutable\").",
|
||||
absolute(exe).generic_string());
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -192,15 +192,15 @@ BaseLocation DBUpdater<T>::GetBaseLocationType()
|
||||
template<class T>
|
||||
bool DBUpdater<T>::Create(DatabaseWorkerPool<T>& pool)
|
||||
{
|
||||
TC_LOG_INFO("sql.updates", "Database \"%s\" does not exist, do you want to create it? [yes (default) / no]: ",
|
||||
pool.GetConnectionInfo()->database.c_str());
|
||||
TC_LOG_INFO("sql.updates", "Database \"{}\" does not exist, do you want to create it? [yes (default) / no]: ",
|
||||
pool.GetConnectionInfo()->database);
|
||||
|
||||
std::string answer;
|
||||
std::getline(std::cin, answer);
|
||||
if (!answer.empty() && !(answer.substr(0, 1) == "y"))
|
||||
return false;
|
||||
|
||||
TC_LOG_INFO("sql.updates", "Creating database \"%s\"...", pool.GetConnectionInfo()->database.c_str());
|
||||
TC_LOG_INFO("sql.updates", "Creating database \"{}\"...", pool.GetConnectionInfo()->database);
|
||||
|
||||
// Path of temp file
|
||||
static Path const temp("create_table.sql");
|
||||
@@ -209,7 +209,7 @@ bool DBUpdater<T>::Create(DatabaseWorkerPool<T>& pool)
|
||||
std::ofstream file(temp.generic_string());
|
||||
if (!file.is_open())
|
||||
{
|
||||
TC_LOG_FATAL("sql.updates", "Failed to create temporary query file \"%s\"!", temp.generic_string().c_str());
|
||||
TC_LOG_FATAL("sql.updates", "Failed to create temporary query file \"{}\"!", temp.generic_string());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -224,7 +224,7 @@ bool DBUpdater<T>::Create(DatabaseWorkerPool<T>& pool)
|
||||
}
|
||||
catch (UpdateException&)
|
||||
{
|
||||
TC_LOG_FATAL("sql.updates", "Failed to create database %s! Does the user (named in *.conf) have `CREATE`, `ALTER`, `DROP`, `INSERT` and `DELETE` privileges on the MySQL server?", pool.GetConnectionInfo()->database.c_str());
|
||||
TC_LOG_FATAL("sql.updates", "Failed to create database {}! Does the user (named in *.conf) have `CREATE`, `ALTER`, `DROP`, `INSERT` and `DELETE` privileges on the MySQL server?", pool.GetConnectionInfo()->database);
|
||||
boost::filesystem::remove(temp);
|
||||
return false;
|
||||
}
|
||||
@@ -240,13 +240,13 @@ bool DBUpdater<T>::Update(DatabaseWorkerPool<T>& pool)
|
||||
if (!DBUpdaterUtil::CheckExecutable())
|
||||
return false;
|
||||
|
||||
TC_LOG_INFO("sql.updates", "Updating %s database...", DBUpdater<T>::GetTableName().c_str());
|
||||
TC_LOG_INFO("sql.updates", "Updating {} database...", DBUpdater<T>::GetTableName());
|
||||
|
||||
Path const sourceDirectory(BuiltInConfig::GetSourceDirectory());
|
||||
|
||||
if (!is_directory(sourceDirectory))
|
||||
{
|
||||
TC_LOG_ERROR("sql.updates", "DBUpdater: The given source directory %s does not exist, change the path to the directory where your sql directory exists (for example c:\\source\\trinitycore). Shutting down.", sourceDirectory.generic_string().c_str());
|
||||
TC_LOG_ERROR("sql.updates", "DBUpdater: The given source directory {} does not exist, change the path to the directory where your sql directory exists (for example c:\\source\\trinitycore). Shutting down.", sourceDirectory.generic_string());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -268,13 +268,13 @@ bool DBUpdater<T>::Update(DatabaseWorkerPool<T>& pool)
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string const info = Trinity::StringFormat("Containing " SZFMTD " new and " SZFMTD " archived updates.",
|
||||
std::string const info = Trinity::StringFormat("Containing {} new and {} archived updates.",
|
||||
result.recent, result.archived);
|
||||
|
||||
if (!result.updated)
|
||||
TC_LOG_INFO("sql.updates", ">> %s database is up-to-date! %s", DBUpdater<T>::GetTableName().c_str(), info.c_str());
|
||||
TC_LOG_INFO("sql.updates", ">> {} database is up-to-date! {}", DBUpdater<T>::GetTableName(), info);
|
||||
else
|
||||
TC_LOG_INFO("sql.updates", ">> Applied " SZFMTD " %s. %s", result.updated, result.updated == 1 ? "query" : "queries", info.c_str());
|
||||
TC_LOG_INFO("sql.updates", ">> Applied {} {}. {}", result.updated, result.updated == 1 ? "query" : "queries", info);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -291,7 +291,7 @@ bool DBUpdater<T>::Populate(DatabaseWorkerPool<T>& pool)
|
||||
if (!DBUpdaterUtil::CheckExecutable())
|
||||
return false;
|
||||
|
||||
TC_LOG_INFO("sql.updates", "Database %s is empty, auto populating it...", DBUpdater<T>::GetTableName().c_str());
|
||||
TC_LOG_INFO("sql.updates", "Database {} is empty, auto populating it...", DBUpdater<T>::GetTableName());
|
||||
|
||||
std::string const p = DBUpdater<T>::GetBaseFile();
|
||||
if (p.empty())
|
||||
@@ -307,8 +307,8 @@ bool DBUpdater<T>::Populate(DatabaseWorkerPool<T>& pool)
|
||||
{
|
||||
case LOCATION_REPOSITORY:
|
||||
{
|
||||
TC_LOG_ERROR("sql.updates", ">> Base file \"%s\" is missing. Try fixing it by cloning the source again.",
|
||||
base.generic_string().c_str());
|
||||
TC_LOG_ERROR("sql.updates", ">> Base file \"{}\" is missing. Try fixing it by cloning the source again.",
|
||||
base.generic_string());
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -316,8 +316,8 @@ bool DBUpdater<T>::Populate(DatabaseWorkerPool<T>& pool)
|
||||
{
|
||||
std::string const filename = base.filename().generic_string();
|
||||
std::string const workdir = boost::filesystem::current_path().generic_string();
|
||||
TC_LOG_ERROR("sql.updates", ">> File \"%s\" is missing, download it from \"https://github.com/TrinityCore/TrinityCore/releases\"" \
|
||||
" uncompress it and place the file \"%s\" in the directory \"%s\".", filename.c_str(), filename.c_str(), workdir.c_str());
|
||||
TC_LOG_ERROR("sql.updates", ">> File \"{}\" is missing, download it from \"https://github.com/TrinityCore/TrinityCore/releases\"" \
|
||||
" uncompress it and place the file \"{}\" in the directory \"{}\".", filename, filename, workdir);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -325,7 +325,7 @@ bool DBUpdater<T>::Populate(DatabaseWorkerPool<T>& pool)
|
||||
}
|
||||
|
||||
// Update database
|
||||
TC_LOG_INFO("sql.updates", ">> Applying \'%s\'...", base.generic_string().c_str());
|
||||
TC_LOG_INFO("sql.updates", ">> Applying \'{}\'...", base.generic_string());
|
||||
try
|
||||
{
|
||||
ApplyFile(pool, base);
|
||||
@@ -416,7 +416,7 @@ void DBUpdater<T>::ApplyFile(DatabaseWorkerPool<T>& pool, std::string const& hos
|
||||
|
||||
// Execute sql file
|
||||
args.emplace_back("-e");
|
||||
args.emplace_back(Trinity::StringFormat("BEGIN; SOURCE %s; COMMIT;", path.generic_string().c_str()));
|
||||
args.emplace_back(Trinity::StringFormat("BEGIN; SOURCE {}; COMMIT;", path.generic_string()));
|
||||
|
||||
// Database
|
||||
if (!database.empty())
|
||||
@@ -428,12 +428,12 @@ void DBUpdater<T>::ApplyFile(DatabaseWorkerPool<T>& pool, std::string const& hos
|
||||
|
||||
if (ret != EXIT_SUCCESS)
|
||||
{
|
||||
TC_LOG_FATAL("sql.updates", "Applying of file \'%s\' to database \'%s\' failed!" \
|
||||
TC_LOG_FATAL("sql.updates", "Applying of file \'{}\' to database \'{}\' failed!" \
|
||||
" If you are a user, please pull the latest revision from the repository. "
|
||||
"Also make sure you have not applied any of the databases with your sql client. "
|
||||
"You cannot use auto-update system and import sql files from TrinityCore repository with your sql client. "
|
||||
"If you are a developer, please fix your sql query.",
|
||||
path.generic_string().c_str(), pool.GetConnectionInfo()->database.c_str());
|
||||
path.generic_string(), pool.GetConnectionInfo()->database);
|
||||
|
||||
throw UpdateException("update failed");
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ void UpdateFetcher::FillFileListRecursively(Path const& path, LocaleFileStorage&
|
||||
}
|
||||
else if (itr->path().extension() == ".sql")
|
||||
{
|
||||
TC_LOG_TRACE("sql.updates", "Added locale file \"%s\".", itr->path().filename().generic_string().c_str());
|
||||
TC_LOG_TRACE("sql.updates", "Added locale file \"{}\".", itr->path().filename().generic_string());
|
||||
|
||||
LocaleFileEntry const entry = { itr->path(), state };
|
||||
|
||||
@@ -82,8 +82,8 @@ void UpdateFetcher::FillFileListRecursively(Path const& path, LocaleFileStorage&
|
||||
// Because elements are only compared by their filenames, this is ok
|
||||
if (storage.find(entry) != storage.end())
|
||||
{
|
||||
TC_LOG_FATAL("sql.updates", "Duplicate filename \"%s\" occurred. Because updates are ordered " \
|
||||
"by their filenames, every name needs to be unique!", itr->path().generic_string().c_str());
|
||||
TC_LOG_FATAL("sql.updates", "Duplicate filename \"{}\" occurred. Because updates are ordered " \
|
||||
"by their filenames, every name needs to be unique!", itr->path().generic_string());
|
||||
|
||||
throw UpdateException("Updating failed, see the log for details.");
|
||||
}
|
||||
@@ -113,14 +113,14 @@ UpdateFetcher::DirectoryStorage UpdateFetcher::ReceiveIncludedDirectories() cons
|
||||
|
||||
if (!is_directory(p))
|
||||
{
|
||||
TC_LOG_WARN("sql.updates", "DBUpdater: Given update include directory \"%s\" does not exist, skipped!", p.generic_string().c_str());
|
||||
TC_LOG_WARN("sql.updates", "DBUpdater: Given update include directory \"{}\" does not exist, skipped!", p.generic_string());
|
||||
continue;
|
||||
}
|
||||
|
||||
DirectoryEntry const entry = { p, AppliedFileEntry::StateConvert(fields[1].GetString()) };
|
||||
directories.push_back(entry);
|
||||
|
||||
TC_LOG_TRACE("sql.updates", "Added applied file \"%s\" from remote.", p.filename().generic_string().c_str());
|
||||
TC_LOG_TRACE("sql.updates", "Added applied file \"{}\" from remote.", p.filename().generic_string());
|
||||
|
||||
} while (result->NextRow());
|
||||
|
||||
@@ -154,10 +154,10 @@ std::string UpdateFetcher::ReadSQLUpdate(boost::filesystem::path const& file) co
|
||||
std::ifstream in(file.c_str());
|
||||
if (!in.is_open())
|
||||
{
|
||||
TC_LOG_FATAL("sql.updates", "Failed to open the sql update \"%s\" for reading! "
|
||||
TC_LOG_FATAL("sql.updates", "Failed to open the sql update \"{}\" for reading! "
|
||||
"Stopping the server to keep the database integrity, "
|
||||
"try to identify and solve the issue or disable the database updater.",
|
||||
file.generic_string().c_str());
|
||||
file.generic_string());
|
||||
|
||||
throw UpdateException("Opening the sql update failed!");
|
||||
}
|
||||
@@ -199,7 +199,7 @@ UpdateResult UpdateFetcher::Update(bool const redundancyChecks,
|
||||
|
||||
for (auto const& availableQuery : available)
|
||||
{
|
||||
TC_LOG_DEBUG("sql.updates", "Checking update \"%s\"...", availableQuery.first.filename().generic_string().c_str());
|
||||
TC_LOG_DEBUG("sql.updates", "Checking update \"{}\"...", availableQuery.first.filename().generic_string());
|
||||
|
||||
AppliedFileStorage::const_iterator iter = applied.find(availableQuery.first.filename().string());
|
||||
if (iter != applied.end())
|
||||
@@ -242,16 +242,16 @@ UpdateResult UpdateFetcher::Update(bool const redundancyChecks,
|
||||
// Conflict!
|
||||
if (localeIter != available.end())
|
||||
{
|
||||
TC_LOG_WARN("sql.updates", ">> It seems like the update \"%s\" \'%s\' was renamed, but the old file is still there! " \
|
||||
"Treating it as a new file! (It is probably an unmodified copy of the file \"%s\")",
|
||||
availableQuery.first.filename().string().c_str(), hash.substr(0, 7).c_str(),
|
||||
localeIter->first.filename().string().c_str());
|
||||
TC_LOG_WARN("sql.updates", ">> It seems like the update \"{}\" \'{}\' was renamed, but the old file is still there! " \
|
||||
"Treating it as a new file! (It is probably an unmodified copy of the file \"{}\")",
|
||||
availableQuery.first.filename().string(), hash.substr(0, 7),
|
||||
localeIter->first.filename().string());
|
||||
}
|
||||
// It is safe to treat the file as renamed here
|
||||
else
|
||||
{
|
||||
TC_LOG_INFO("sql.updates", ">> Renaming update \"%s\" to \"%s\" \'%s\'.",
|
||||
hashIter->second.c_str(), availableQuery.first.filename().string().c_str(), hash.substr(0, 7).c_str());
|
||||
TC_LOG_INFO("sql.updates", ">> Renaming update \"{}\" to \"{}\" \'{}\'.",
|
||||
hashIter->second, availableQuery.first.filename().string(), hash.substr(0, 7));
|
||||
|
||||
RenameEntry(hashIter->second, availableQuery.first.filename().string());
|
||||
applied.erase(hashIter->second);
|
||||
@@ -261,8 +261,8 @@ UpdateResult UpdateFetcher::Update(bool const redundancyChecks,
|
||||
// Apply the update if it was never seen before.
|
||||
else
|
||||
{
|
||||
TC_LOG_INFO("sql.updates", ">> Applying update \"%s\" \'%s\'...",
|
||||
availableQuery.first.filename().string().c_str(), hash.substr(0, 7).c_str());
|
||||
TC_LOG_INFO("sql.updates", ">> Applying update \"{}\" \'{}\'...",
|
||||
availableQuery.first.filename().string(), hash.substr(0, 7));
|
||||
}
|
||||
}
|
||||
// Rehash the update entry if it exists in our database with an empty hash.
|
||||
@@ -270,29 +270,29 @@ UpdateResult UpdateFetcher::Update(bool const redundancyChecks,
|
||||
{
|
||||
mode = MODE_REHASH;
|
||||
|
||||
TC_LOG_INFO("sql.updates", ">> Re-hashing update \"%s\" \'%s\'...", availableQuery.first.filename().string().c_str(),
|
||||
hash.substr(0, 7).c_str());
|
||||
TC_LOG_INFO("sql.updates", ">> Re-hashing update \"{}\" \'{}\'...", availableQuery.first.filename().string(),
|
||||
hash.substr(0, 7));
|
||||
}
|
||||
else
|
||||
{
|
||||
// If the hash of the files differs from the one stored in our database, reapply the update (because it changed).
|
||||
if (iter->second.hash != hash)
|
||||
{
|
||||
TC_LOG_INFO("sql.updates", ">> Reapplying update \"%s\" \'%s\' -> \'%s\' (it changed)...", availableQuery.first.filename().string().c_str(),
|
||||
iter->second.hash.substr(0, 7).c_str(), hash.substr(0, 7).c_str());
|
||||
TC_LOG_INFO("sql.updates", ">> Reapplying update \"{}\" \'{}\' -> \'{}\' (it changed)...", availableQuery.first.filename().string(),
|
||||
iter->second.hash.substr(0, 7), hash.substr(0, 7));
|
||||
}
|
||||
else
|
||||
{
|
||||
// If the file wasn't changed and just moved, update its state (if necessary).
|
||||
if (iter->second.state != availableQuery.second)
|
||||
{
|
||||
TC_LOG_DEBUG("sql.updates", ">> Updating the state of \"%s\" to \'%s\'...",
|
||||
availableQuery.first.filename().string().c_str(), AppliedFileEntry::StateConvert(availableQuery.second).c_str());
|
||||
TC_LOG_DEBUG("sql.updates", ">> Updating the state of \"{}\" to \'{}\'...",
|
||||
availableQuery.first.filename().string(), AppliedFileEntry::StateConvert(availableQuery.second));
|
||||
|
||||
UpdateState(availableQuery.first.filename().string(), availableQuery.second);
|
||||
}
|
||||
|
||||
TC_LOG_DEBUG("sql.updates", ">> Update is already applied and matches the hash \'%s\'.", hash.substr(0, 7).c_str());
|
||||
TC_LOG_DEBUG("sql.updates", ">> Update is already applied and matches the hash \'{}\'.", hash.substr(0, 7));
|
||||
|
||||
applied.erase(iter);
|
||||
continue;
|
||||
@@ -326,18 +326,18 @@ UpdateResult UpdateFetcher::Update(bool const redundancyChecks,
|
||||
|
||||
for (auto const& entry : applied)
|
||||
{
|
||||
TC_LOG_WARN("sql.updates", ">> The file \'%s\' was applied to the database, but is missing in" \
|
||||
" your update directory now!", entry.first.c_str());
|
||||
TC_LOG_WARN("sql.updates", ">> The file \'{}\' was applied to the database, but is missing in" \
|
||||
" your update directory now!", entry.first);
|
||||
|
||||
if (doCleanup)
|
||||
TC_LOG_INFO("sql.updates", "Deleting orphaned entry \'%s\'...", entry.first.c_str());
|
||||
TC_LOG_INFO("sql.updates", "Deleting orphaned entry \'{}\'...", entry.first);
|
||||
}
|
||||
|
||||
if (doCleanup)
|
||||
CleanUp(applied);
|
||||
else
|
||||
{
|
||||
TC_LOG_ERROR("sql.updates", "Cleanup is disabled! There were " SZFMTD " dirty files applied to your database, " \
|
||||
TC_LOG_ERROR("sql.updates", "Cleanup is disabled! There were {} dirty files applied to your database, " \
|
||||
"but they are now missing in your source directory!", applied.size());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user