I got tired of the crappy format (no pun intended) of the gmcommands.log so I made this mod. What it does is instead of logging all actions to gmcommands.log is putting all the data in a specific table in the database.
How to use:
Replace the whole section
Code:
Code:
void SessionLogWriter::writefromsession(WorldSession* session, const char* format, ...)
{
...
}
in WorldSession.cpp, line 862 with this:
Code:
Code:
void SessionLogWriter::writefromsession(WorldSession* session, const char* format, ...)
{
if(!IsOpen())
return;
va_list ap;
va_start(ap, format);
char out2[32768];
char thetime[32768];
time_t t = UNIXTIME;
tm* aTm = localtime(&t);
snprintf(thetime, 32768, "%-4d-%02d-%02d %02d:%02d:%02d",aTm->tm_year+1900,aTm->tm_mon+1,aTm->tm_mday,aTm->tm_hour,aTm->tm_min,aTm->tm_sec);
vsnprintf(out2, 32768, format, ap);
QueryResult * result = CharacterDatabase.Query("INSERT INTO `gmcommands` (`ip`,`time`,`account`,`player`,`info`) VALUES ('%s','%s','%s','%s','%s')",
session->GetSocket() ? session->GetSocket()->GetRemoteIP().c_str() : "NOIP",
thetime,
session->GetAccountName().c_str(),
session->GetPlayer() ? session->GetPlayer()->GetName() : "nologin",
out2);
fflush(m_file);
va_end(ap);
}
If you want to customize the way data is entered in the DB just modify the query above.
And here's the structure of the gmcommands table (you must create it in your character database):
Code:
Code:
-- ----------------------------
-- Table structure for gmcommands
-- ----------------------------
CREATE TABLE `gmcommands` (
`id` bigint(20) NOT NULL auto_increment,
`time` timestamp NULL default NULL,
`ip` varchar(255) default NULL,
`account` varchar(255) default NULL,
`player` varchar(255) default NULL,
`info` varchar(255) default NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8;
//iveen
EDIT: Forgot to say, if you have the "log cheaters" option enabled this will also pop-up in your database, so my suggestion is to disable it.