added optimization tweaker

added binary log maxsize support
This commit is contained in:
David Anderson
2006-03-17 22:50:13 +00:00
parent 4bcb0fcb13
commit 2c5520cad0
6 changed files with 47 additions and 9 deletions

View File

@@ -6,6 +6,7 @@
BinLog g_BinLog;
int g_binlog_level = 0;
int g_binlog_maxsize = 0;
bool BinLog::Open()
{
@@ -61,6 +62,20 @@ void BinLog::WriteOp(BinLogOp op, int plug, ...)
if (!fp)
return;
if (g_binlog_maxsize)
{
fseek(fp, 0, SEEK_END);
if (ftell(fp) > (g_binlog_maxsize * (1024 * 1024)))
{
fclose(fp);
Close();
Open();
fp = fopen(m_logfile.c_str(), "ab");
if (!fp)
return;
}
}
unsigned char c = static_cast<char>(op);
time_t t = time(NULL);
float gt = gpGlobals->time;