mirror of
https://github.com/shavitush/bhoptimer.git
synced 2025-12-09 03:18:25 +00:00
add sql logging define
This commit is contained in:
parent
077cbe9a01
commit
2b4d77d281
@ -44,6 +44,8 @@
|
|||||||
#define HUD_NOSOUNDS (1 << 11) // disables sounds on personal best, world record etc
|
#define HUD_NOSOUNDS (1 << 11) // disables sounds on personal best, world record etc
|
||||||
#define HUD_NOPRACALERT (1 << 12) // hides practice mode chat alert
|
#define HUD_NOPRACALERT (1 << 12) // hides practice mode chat alert
|
||||||
|
|
||||||
|
#define SHAVIT_LOG_QUERIES 0
|
||||||
|
|
||||||
// status
|
// status
|
||||||
enum TimerStatus
|
enum TimerStatus
|
||||||
{
|
{
|
||||||
@ -250,6 +252,56 @@ enum struct frame_cache_t
|
|||||||
float fTickrate;
|
float fTickrate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stock void Shavit_LogQuery(const char[] query)
|
||||||
|
{
|
||||||
|
#if SHAVIT_LOG_QUERIES
|
||||||
|
static File hLogFile;
|
||||||
|
|
||||||
|
if (hLogFile == null)
|
||||||
|
{
|
||||||
|
char sPlugin[PLATFORM_MAX_PATH];
|
||||||
|
GetPluginFilename(INVALID_HANDLE, sPlugin, sizeof(sPlugin));
|
||||||
|
ReplaceString(sPlugin, PLATFORM_MAX_PATH, ".smx", "");
|
||||||
|
ReplaceString(sPlugin, PLATFORM_MAX_PATH, "\\", "/");
|
||||||
|
|
||||||
|
int start = FindCharInString(sPlugin, '/', true);
|
||||||
|
|
||||||
|
char sFilename[PLATFORM_MAX_PATH];
|
||||||
|
BuildPath(Path_SM, sFilename, sizeof(sFilename), "logs/%s_sql.log", sPlugin[start+1]);
|
||||||
|
|
||||||
|
hLogFile = OpenFile(sFilename, "a");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hLogFile)
|
||||||
|
{
|
||||||
|
LogToOpenFileEx(hLogFile, "%s", query);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
methodmap Database2 < Database
|
||||||
|
{
|
||||||
|
public void Query(SQLQueryCallback callback, const char[] query, any data = 0, DBPriority prio = DBPrio_Normal)
|
||||||
|
{
|
||||||
|
Shavit_LogQuery(query);
|
||||||
|
this.Query(callback, query, data, prio);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
methodmap Transaction2 < Transaction
|
||||||
|
{
|
||||||
|
public Transaction2()
|
||||||
|
{
|
||||||
|
return view_as<Transaction2>(new Transaction());
|
||||||
|
}
|
||||||
|
|
||||||
|
public int AddQuery(const char[] query, any data = 0)
|
||||||
|
{
|
||||||
|
Shavit_LogQuery(query);
|
||||||
|
return this.AddQuery(query, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if defined USES_CHAT_COLORS
|
#if defined USES_CHAT_COLORS
|
||||||
// hardcoded colors
|
// hardcoded colors
|
||||||
char gS_GlobalColorNames[][] =
|
char gS_GlobalColorNames[][] =
|
||||||
@ -323,6 +375,11 @@ stock Database GetTimerDatabaseHandle()
|
|||||||
return db;
|
return db;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stock Database2 GetTimerDatabaseHandle2()
|
||||||
|
{
|
||||||
|
return view_as<Database2>(GetTimerDatabaseHandle());
|
||||||
|
}
|
||||||
|
|
||||||
// figures out if the database is a mysql database
|
// figures out if the database is a mysql database
|
||||||
stock bool IsMySQLDatabase(Database db)
|
stock bool IsMySQLDatabase(Database db)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -81,7 +81,7 @@ DynamicHook gH_AcceptInput; // used for hooking player_speedmod's AcceptInput
|
|||||||
Handle gH_PhysicsCheckForEntityUntouch;
|
Handle gH_PhysicsCheckForEntityUntouch;
|
||||||
|
|
||||||
// database handle
|
// database handle
|
||||||
Database gH_SQL = null;
|
Database2 gH_SQL = null;
|
||||||
bool gB_MySQL = false;
|
bool gB_MySQL = false;
|
||||||
int gI_MigrationsRequired;
|
int gI_MigrationsRequired;
|
||||||
int gI_MigrationsFinished;
|
int gI_MigrationsFinished;
|
||||||
@ -2995,7 +2995,7 @@ bool LoadMessages()
|
|||||||
void SQL_DBConnect()
|
void SQL_DBConnect()
|
||||||
{
|
{
|
||||||
GetTimerSQLPrefix(gS_MySQLPrefix, 32);
|
GetTimerSQLPrefix(gS_MySQLPrefix, 32);
|
||||||
gH_SQL = GetTimerDatabaseHandle();
|
gH_SQL = GetTimerDatabaseHandle2();
|
||||||
gB_MySQL = IsMySQLDatabase(gH_SQL);
|
gB_MySQL = IsMySQLDatabase(gH_SQL);
|
||||||
|
|
||||||
// support unicode names
|
// support unicode names
|
||||||
@ -3193,7 +3193,7 @@ public void SQL_TableMigrationIPAddresses_Callback(Database db, DBResultSet resu
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Transaction hTransaction = new Transaction();
|
Transaction2 hTransaction = new Transaction2();
|
||||||
int iQueries = 0;
|
int iQueries = 0;
|
||||||
|
|
||||||
while(results.FetchRow())
|
while(results.FetchRow())
|
||||||
|
|||||||
@ -66,7 +66,7 @@ enum struct ranking_t
|
|||||||
}
|
}
|
||||||
|
|
||||||
char gS_MySQLPrefix[32];
|
char gS_MySQLPrefix[32];
|
||||||
Database gH_SQL = null;
|
Database2 gH_SQL = null;
|
||||||
bool gB_HasSQLRANK = false; // whether the sql driver supports RANK()
|
bool gB_HasSQLRANK = false; // whether the sql driver supports RANK()
|
||||||
|
|
||||||
bool gB_Stats = false;
|
bool gB_Stats = false;
|
||||||
@ -218,7 +218,7 @@ public void OnLibraryRemoved(const char[] name)
|
|||||||
public void Shavit_OnDatabaseLoaded()
|
public void Shavit_OnDatabaseLoaded()
|
||||||
{
|
{
|
||||||
GetTimerSQLPrefix(gS_MySQLPrefix, 32);
|
GetTimerSQLPrefix(gS_MySQLPrefix, 32);
|
||||||
gH_SQL = GetTimerDatabaseHandle();
|
gH_SQL = GetTimerDatabaseHandle2();
|
||||||
|
|
||||||
if(!IsMySQLDatabase(gH_SQL))
|
if(!IsMySQLDatabase(gH_SQL))
|
||||||
{
|
{
|
||||||
@ -743,7 +743,7 @@ public Action Command_RecalcAll(int client, int args)
|
|||||||
{
|
{
|
||||||
ReplyToCommand(client, "- Started recalculating points for all maps. Check console for output.");
|
ReplyToCommand(client, "- Started recalculating points for all maps. Check console for output.");
|
||||||
|
|
||||||
Transaction trans = new Transaction();
|
Transaction2 trans = new Transaction2();
|
||||||
char sQuery[1024];
|
char sQuery[1024];
|
||||||
|
|
||||||
FormatEx(sQuery, sizeof(sQuery), "UPDATE %splayertimes SET points = 0;", gS_MySQLPrefix);
|
FormatEx(sQuery, sizeof(sQuery), "UPDATE %splayertimes SET points = 0;", gS_MySQLPrefix);
|
||||||
|
|||||||
@ -286,7 +286,7 @@ TopMenu gH_AdminMenu = null;
|
|||||||
TopMenuObject gH_TimerCommands = INVALID_TOPMENUOBJECT;
|
TopMenuObject gH_TimerCommands = INVALID_TOPMENUOBJECT;
|
||||||
|
|
||||||
// database related things
|
// database related things
|
||||||
Database gH_SQL = null;
|
Database2 gH_SQL = null;
|
||||||
char gS_MySQLPrefix[32];
|
char gS_MySQLPrefix[32];
|
||||||
|
|
||||||
bool gB_ClosestPos;
|
bool gB_ClosestPos;
|
||||||
@ -488,7 +488,7 @@ public void OnPluginStart()
|
|||||||
|
|
||||||
// database
|
// database
|
||||||
GetTimerSQLPrefix(gS_MySQLPrefix, 32);
|
GetTimerSQLPrefix(gS_MySQLPrefix, 32);
|
||||||
gH_SQL = GetTimerDatabaseHandle();
|
gH_SQL = GetTimerDatabaseHandle2();
|
||||||
|
|
||||||
LoadDHooks();
|
LoadDHooks();
|
||||||
|
|
||||||
|
|||||||
@ -40,7 +40,7 @@
|
|||||||
bool gB_Rankings = false;
|
bool gB_Rankings = false;
|
||||||
|
|
||||||
// database handle
|
// database handle
|
||||||
Database gH_SQL = null;
|
Database2 gH_SQL = null;
|
||||||
char gS_MySQLPrefix[32];
|
char gS_MySQLPrefix[32];
|
||||||
|
|
||||||
// cache
|
// cache
|
||||||
@ -109,7 +109,7 @@ public void OnPluginStart()
|
|||||||
|
|
||||||
// database
|
// database
|
||||||
GetTimerSQLPrefix(gS_MySQLPrefix, 32);
|
GetTimerSQLPrefix(gS_MySQLPrefix, 32);
|
||||||
gH_SQL = GetTimerDatabaseHandle();
|
gH_SQL = GetTimerDatabaseHandle2();
|
||||||
|
|
||||||
if(gB_Late)
|
if(gB_Late)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -36,7 +36,7 @@
|
|||||||
// #define DEBUG
|
// #define DEBUG
|
||||||
|
|
||||||
// database handle
|
// database handle
|
||||||
Database gH_SQL = null;
|
Database2 gH_SQL = null;
|
||||||
|
|
||||||
// base cvars
|
// base cvars
|
||||||
ConVar mp_do_warmup_period = null;
|
ConVar mp_do_warmup_period = null;
|
||||||
@ -113,7 +113,7 @@ public void OnPluginStart()
|
|||||||
Convar.AutoExecConfig();
|
Convar.AutoExecConfig();
|
||||||
|
|
||||||
GetTimerSQLPrefix(gS_MySQLPrefix, 32);
|
GetTimerSQLPrefix(gS_MySQLPrefix, 32);
|
||||||
gH_SQL = GetTimerDatabaseHandle();
|
gH_SQL = GetTimerDatabaseHandle2();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnConVarChanged(ConVar convar, const char[] oldValue, const char[] newValue)
|
public void OnConVarChanged(ConVar convar, const char[] oldValue, const char[] newValue)
|
||||||
|
|||||||
@ -58,7 +58,7 @@ Handle gH_OnWorstRecord = null;
|
|||||||
Handle gH_OnFinishMessage = null;
|
Handle gH_OnFinishMessage = null;
|
||||||
|
|
||||||
// database handle
|
// database handle
|
||||||
Database gH_SQL = null;
|
Database2 gH_SQL = null;
|
||||||
bool gB_Connected = false;
|
bool gB_Connected = false;
|
||||||
bool gB_MySQL = false;
|
bool gB_MySQL = false;
|
||||||
|
|
||||||
@ -2144,11 +2144,11 @@ public int SubMenu_Handler(Menu menu, MenuAction action, int param1, int param2)
|
|||||||
public void Shavit_OnDatabaseLoaded()
|
public void Shavit_OnDatabaseLoaded()
|
||||||
{
|
{
|
||||||
GetTimerSQLPrefix(gS_MySQLPrefix, 32);
|
GetTimerSQLPrefix(gS_MySQLPrefix, 32);
|
||||||
gH_SQL = GetTimerDatabaseHandle();
|
gH_SQL = GetTimerDatabaseHandle2();
|
||||||
gB_MySQL = IsMySQLDatabase(gH_SQL);
|
gB_MySQL = IsMySQLDatabase(gH_SQL);
|
||||||
|
|
||||||
char sQuery[1024];
|
char sQuery[1024];
|
||||||
Transaction hTransaction = new Transaction();
|
Transaction2 hTransaction = new Transaction2();
|
||||||
|
|
||||||
if(gB_MySQL)
|
if(gB_MySQL)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -40,7 +40,7 @@
|
|||||||
|
|
||||||
EngineVersion gEV_Type = Engine_Unknown;
|
EngineVersion gEV_Type = Engine_Unknown;
|
||||||
|
|
||||||
Database gH_SQL = null;
|
Database2 gH_SQL = null;
|
||||||
bool gB_Connected = false;
|
bool gB_Connected = false;
|
||||||
bool gB_MySQL = false;
|
bool gB_MySQL = false;
|
||||||
bool gB_InsertedPrebuiltZones = false;
|
bool gB_InsertedPrebuiltZones = false;
|
||||||
@ -3240,10 +3240,10 @@ void CreateZonePoints(float point[8][3], float offset = 0.0)
|
|||||||
public void Shavit_OnDatabaseLoaded()
|
public void Shavit_OnDatabaseLoaded()
|
||||||
{
|
{
|
||||||
GetTimerSQLPrefix(gS_MySQLPrefix, 32);
|
GetTimerSQLPrefix(gS_MySQLPrefix, 32);
|
||||||
gH_SQL = GetTimerDatabaseHandle();
|
gH_SQL = GetTimerDatabaseHandle2();
|
||||||
gB_MySQL = IsMySQLDatabase(gH_SQL);
|
gB_MySQL = IsMySQLDatabase(gH_SQL);
|
||||||
|
|
||||||
Transaction hTransaction = new Transaction();
|
Transaction2 hTransaction = new Transaction2();
|
||||||
|
|
||||||
char sQuery[1024];
|
char sQuery[1024];
|
||||||
FormatEx(sQuery, 1024,
|
FormatEx(sQuery, 1024,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user