mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-15 04:28:20 +00:00
Merge pull request #9020 from ChillerDragon/pr_dbg_sql
Add ``dbg_sql`` config to hide non error sql logs
This commit is contained in:
commit
73357a45dc
|
@ -1,5 +1,6 @@
|
||||||
#include "connection_pool.h"
|
#include "connection_pool.h"
|
||||||
#include "connection.h"
|
#include "connection.h"
|
||||||
|
#include <engine/shared/config.h>
|
||||||
|
|
||||||
#include <base/system.h>
|
#include <base/system.h>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
@ -186,11 +187,13 @@ void CDbConnectionPool::OnShutdown()
|
||||||
class CBackup
|
class CBackup
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CBackup(std::shared_ptr<CDbConnectionPool::CSharedData> pShared) :
|
CBackup(std::shared_ptr<CDbConnectionPool::CSharedData> pShared, int DebugSql) :
|
||||||
m_pShared(std::move(pShared)) {}
|
m_DebugSql(DebugSql), m_pShared(std::move(pShared)) {}
|
||||||
static void Start(void *pUser);
|
static void Start(void *pUser);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool m_DebugSql;
|
||||||
|
|
||||||
void ProcessQueries();
|
void ProcessQueries();
|
||||||
|
|
||||||
std::unique_ptr<IDbConnection> m_pWriteBackup;
|
std::unique_ptr<IDbConnection> m_pWriteBackup;
|
||||||
|
@ -228,6 +231,7 @@ void CBackup::ProcessQueries()
|
||||||
else if(pThreadData->m_Mode == CSqlExecData::WRITE_ACCESS && m_pWriteBackup.get())
|
else if(pThreadData->m_Mode == CSqlExecData::WRITE_ACCESS && m_pWriteBackup.get())
|
||||||
{
|
{
|
||||||
bool Success = CDbConnectionPool::ExecSqlFunc(m_pWriteBackup.get(), pThreadData, Write::BACKUP_FIRST);
|
bool Success = CDbConnectionPool::ExecSqlFunc(m_pWriteBackup.get(), pThreadData, Write::BACKUP_FIRST);
|
||||||
|
if(m_DebugSql || !Success)
|
||||||
dbg_msg("sql", "[%i] %s done on write backup database, Success=%i", JobNum, pThreadData->m_pName, Success);
|
dbg_msg("sql", "[%i] %s done on write backup database, Success=%i", JobNum, pThreadData->m_pName, Success);
|
||||||
}
|
}
|
||||||
m_pShared->m_NumWorker.Signal();
|
m_pShared->m_NumWorker.Signal();
|
||||||
|
@ -241,14 +245,16 @@ void CBackup::ProcessQueries()
|
||||||
class CWorker
|
class CWorker
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CWorker(std::shared_ptr<CDbConnectionPool::CSharedData> pShared) :
|
CWorker(std::shared_ptr<CDbConnectionPool::CSharedData> pShared, int DebugSql) :
|
||||||
m_pShared(std::move(pShared)) {}
|
m_DebugSql(DebugSql), m_pShared(std::move(pShared)) {}
|
||||||
static void Start(void *pUser);
|
static void Start(void *pUser);
|
||||||
void ProcessQueries();
|
void ProcessQueries();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Print(IConsole *pConsole, CDbConnectionPool::Mode DatabaseMode);
|
void Print(IConsole *pConsole, CDbConnectionPool::Mode DatabaseMode);
|
||||||
|
|
||||||
|
bool m_DebugSql;
|
||||||
|
|
||||||
// There are two possible configurations
|
// There are two possible configurations
|
||||||
// * sqlite mode: There exists exactly one READ and the same WRITE server
|
// * sqlite mode: There exists exactly one READ and the same WRITE server
|
||||||
// with no WRITE_BACKUP server
|
// with no WRITE_BACKUP server
|
||||||
|
@ -314,6 +320,7 @@ void CWorker::ProcessQueries()
|
||||||
if(CDbConnectionPool::ExecSqlFunc(m_vpReadConnections[CurServer].get(), pThreadData.get(), Write::NORMAL))
|
if(CDbConnectionPool::ExecSqlFunc(m_vpReadConnections[CurServer].get(), pThreadData.get(), Write::NORMAL))
|
||||||
{
|
{
|
||||||
ReadServer = CurServer;
|
ReadServer = CurServer;
|
||||||
|
if(m_DebugSql)
|
||||||
dbg_msg("sql", "[%i] %s done on read database %d", JobNum, pThreadData->m_pName, CurServer);
|
dbg_msg("sql", "[%i] %s done on read database %d", JobNum, pThreadData->m_pName, CurServer);
|
||||||
Success = true;
|
Success = true;
|
||||||
break;
|
break;
|
||||||
|
@ -337,6 +344,7 @@ void CWorker::ProcessQueries()
|
||||||
}
|
}
|
||||||
else if(CDbConnectionPool::ExecSqlFunc(m_pWriteConnection.get(), pThreadData.get(), Write::NORMAL))
|
else if(CDbConnectionPool::ExecSqlFunc(m_pWriteConnection.get(), pThreadData.get(), Write::NORMAL))
|
||||||
{
|
{
|
||||||
|
if(m_DebugSql)
|
||||||
dbg_msg("sql", "[%i] %s done on write database", JobNum, pThreadData->m_pName);
|
dbg_msg("sql", "[%i] %s done on write database", JobNum, pThreadData->m_pName);
|
||||||
Success = true;
|
Success = true;
|
||||||
}
|
}
|
||||||
|
@ -345,6 +353,7 @@ void CWorker::ProcessQueries()
|
||||||
const Write w = Success ? Write::NORMAL_SUCCEEDED : Write::NORMAL_FAILED;
|
const Write w = Success ? Write::NORMAL_SUCCEEDED : Write::NORMAL_FAILED;
|
||||||
if(m_pWriteBackup && CDbConnectionPool::ExecSqlFunc(m_pWriteBackup.get(), pThreadData.get(), w))
|
if(m_pWriteBackup && CDbConnectionPool::ExecSqlFunc(m_pWriteBackup.get(), pThreadData.get(), w))
|
||||||
{
|
{
|
||||||
|
if(m_DebugSql)
|
||||||
dbg_msg("sql", "[%i] %s done move write on backup database to non-backup table", JobNum, pThreadData->m_pName);
|
dbg_msg("sql", "[%i] %s done move write on backup database to non-backup table", JobNum, pThreadData->m_pName);
|
||||||
Success = true;
|
Success = true;
|
||||||
}
|
}
|
||||||
|
@ -467,8 +476,8 @@ bool CDbConnectionPool::ExecSqlFunc(IDbConnection *pConnection, CSqlExecData *pD
|
||||||
CDbConnectionPool::CDbConnectionPool()
|
CDbConnectionPool::CDbConnectionPool()
|
||||||
{
|
{
|
||||||
m_pShared = std::make_shared<CSharedData>();
|
m_pShared = std::make_shared<CSharedData>();
|
||||||
m_pWorkerThread = thread_init(CWorker::Start, new CWorker(m_pShared), "database worker thread");
|
m_pWorkerThread = thread_init(CWorker::Start, new CWorker(m_pShared, g_Config.m_DbgSql), "database worker thread");
|
||||||
m_pBackupThread = thread_init(CBackup::Start, new CBackup(m_pShared), "database backup worker thread");
|
m_pBackupThread = thread_init(CBackup::Start, new CBackup(m_pShared, g_Config.m_DbgSql), "database backup worker thread");
|
||||||
}
|
}
|
||||||
|
|
||||||
CDbConnectionPool::~CDbConnectionPool()
|
CDbConnectionPool::~CDbConnectionPool()
|
||||||
|
|
|
@ -465,6 +465,7 @@ MACRO_CONFIG_INT(EcAuthTimeout, ec_auth_timeout, 30, 1, 120, CFGFLAG_ECON, "Time
|
||||||
MACRO_CONFIG_INT(EcOutputLevel, ec_output_level, 0, -3, 2, CFGFLAG_ECON, "Adjusts the amount of information in the external console (-3 = none, -2 = error only, -1 = warn, 0 = info, 1 = debug, 2 = trace)")
|
MACRO_CONFIG_INT(EcOutputLevel, ec_output_level, 0, -3, 2, CFGFLAG_ECON, "Adjusts the amount of information in the external console (-3 = none, -2 = error only, -1 = warn, 0 = info, 1 = debug, 2 = trace)")
|
||||||
|
|
||||||
MACRO_CONFIG_INT(Debug, debug, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SERVER, "Debug mode")
|
MACRO_CONFIG_INT(Debug, debug, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SERVER, "Debug mode")
|
||||||
|
MACRO_CONFIG_INT(DbgSql, dbg_sql, 1, 0, 1, CFGFLAG_SERVER, "Debug SQL")
|
||||||
MACRO_CONFIG_INT(DbgCurl, dbg_curl, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SERVER, "Debug curl")
|
MACRO_CONFIG_INT(DbgCurl, dbg_curl, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SERVER, "Debug curl")
|
||||||
MACRO_CONFIG_INT(DbgGraphs, dbg_graphs, 0, 0, 1, CFGFLAG_CLIENT, "Performance graphs")
|
MACRO_CONFIG_INT(DbgGraphs, dbg_graphs, 0, 0, 1, CFGFLAG_CLIENT, "Performance graphs")
|
||||||
MACRO_CONFIG_INT(DbgGfx, dbg_gfx, 0, 0, 4, CFGFLAG_CLIENT, "Show graphic library warnings and errors, if the GPU supports it (0: none, 1: minimal, 2: affects performance, 3: verbose, 4: all)")
|
MACRO_CONFIG_INT(DbgGfx, dbg_gfx, 0, 0, 4, CFGFLAG_CLIENT, "Show graphic library warnings and errors, if the GPU supports it (0: none, 1: minimal, 2: affects performance, 3: verbose, 4: all)")
|
||||||
|
|
Loading…
Reference in a new issue