I like to keep logs, and with AOLIM, this is no exception. I use one of the rare releases that supports automated logging. I currently have the capability to read the log file into PHP (I tried in C++, but because of the lack of REGEX, it made it a bit more difficult), and my goal is to split up logs into individual files. The basic content of the HTML log is:
<hR> 2001/02/28 22:36:12 IM with -SCREENNAME---htmlstuffhere--</HTML<hR>--new entry here--
And my code is as follows (it reads in the whole "2001/02/28 22:36:12 IM with -SCREENNAME-" from IMLog.txt, which stores a list of all log entries (making searching very easy):
$fd = join('',file("$AIMLOGROOT\$screenname\IMLog.htm"));
while (count($ims) > 0)//$ims = the list of ims, broken down in a different function
{
$imstart = trim($ims[0]["FULLSTRING"]);//the whole MM/DD/YYY HH:MM:SS IM with -SCREENNAME- portion
$imend = trim($ims[1]["FULLSTRING"]);
if (ereg("(<hR>** $imstart)(.*)(<hR>** $imend)",$fd,$regs))
{
//do stuff here with $regs[2]
$fd=str_replace($regs[1].$regs[2],"",$fd);//remove the previous block / archive it (later)
array_shift($ims);
}
}
Now the problem is that I currently have a 2MB log file, and this script only manages to parse about 20 entries in 5 minutes (and thats on a 800mhz computer). I am wondering if there is something that I might be doing wrong that keeps this from working quickly. the portion with (.*) is of a VERY variable length, which I could see as causing a problem, but not this major. Thanks for any help!