Log file manager

Larsen

Lifetimer
Joined
Aug 16, 2006
Messages
113
Reaction score
0
Points
0
I'm looking for a utility/plugin that would manage my EQ log files for me.

I don't tend to refer to my log files very often in EQ, although I do have them switched on. I came to look for something in my log file last night and the damn thing is over 400mb! Just managing that thing in notepad is a labourious task.

What I'd like is a utility/plugin that automatically renames my log file either at the start of each session or each day.

Anyone know of an existing tool that will do this?
 
I just use a windows script. It just moves the active log file into the Archieve folder and appends it to the existing one.
It would be a simple change to just save it by day as well. Just look at the code I have to move the screenshots.

I marked the parts that you will have to edit in orange.

Code:
'----------------
' Log File Append
'----------------
set objFSO = CreateObject("Scripting.FilesystemObject")

'Define File Names (set these to your own character names and the Dim to the max number you are using)
'Set this to the number of characters you are looking for. Starts at "0"

Dim myarray(6) 
myarray(0) = "[COLOR="DarkOrange"]Name[/COLOR]"
myarray(1) = "[COLOR="darkorange"]Name[/COLOR]"
myarray(2) = "[COLOR="DarkOrange"]Name[/COLOR]"
myarray(3) = "[COLOR="darkorange"]Name[/COLOR]"
myarray(4) = "[COLOR="darkorange"]Name[/COLOR]"
myarray(5) = "[COLOR="darkorange"]Name[/COLOR]"
myarray(6) = "[COLOR="darkorange"]Name[/COLOR]"
Dim Sucess, Failed, LogName, ArchLog
Sucess = ""
Failed = ""

'Steps through the characters 
For Each character in myarray
	'You can modify the directory paths and server name. 
	'The script can support any nmber of servers
	LogName = "C:\[COLOR="darkorange"]Program Files\EverQuest[/COLOR]\logs\eqlog_"& character &"_[COLOR="darkorange"]server[/COLOR].txt" 
	ArchLog = "C:\[COLOR="darkorange"]Program Files\EverQuest[/COLOR]\logs\Archive\eqlog_"& character &"_[COLOR="darkorange"]server[/COLOR].txt"
	'Write the original log to the archieve
	'I have to read through because I am appending it to the Archieve copy
	if objFSO.FileExists(LogName) then
		set handle = objFSO.OpenTextFile(LogName, 1, false, useDefault)
		set handle2 = objFSO.OpenTextFile(ArchLog, 8, true, useDefault)
		handle2.WriteLine ""
		handle2.WriteLine "["& Now() &"]    *** New File Appended *** "
		do until handle.atEndOfStream
			line = handle.ReadLine
			handle2.WriteLine line
			loop
		handle.close
		handle2.close
		set CleanUP = objFSO.GetFile(LogName)
		CleanUp.Delete()
		Sucess = Sucess & vbCR & character
		'MsgBox "Log File Joined to ArchLog and Original Deleted"
	else
	    Failed = Failed  & "No file found for "& Character & vbCR
	end if
Next
Message = "The following character log files"& vbCR & "were appended to their archieve logs." & vbCR 
Message = Message & vbCR & Sucess & vbCR & Failed
	
MsgBox Message, vbInformation
	
Set objFSO = Nothing

'---------------------------------------------------
'Move Screenshots to Archieve in folder for that day
'---------------------------------------------------
Set fs = CreateObject("Scripting.FileSystemOBJECT")
'This is used to create the folder name to store the image files in
'primarily because all EQ screenshots are named EQ0000##.bmp
foldname = Year(Now) & "." & Month(Now) & "." & Day(Now)

'Set the Source and Dest to your folder names.
source = "[COLOR="darkorange"]C:\Program Files\EverQuest\Screenshots[/COLOR]"
dest   = "[COLOR="DarkOrange"]C:\Program Files\EverQuest\logs\Archive\Images\[/COLOR]" & foldname & "\"

'Not needed but I like to initialize the counter anyway.
counter1 = 0

filesmoved = ""
For counter = 0 to 99 
	If counter < 10 then
		ImageFileName = source & "EQ00000" & counter & ".bmp"
		else
		ImageFileName = source & "EQ0000" & counter & ".bmp"
		end if
	path = fs.GetAbsolutePathName(ImageFileName)
	If fs.FileExists(path) Then
		If Not fs.FolderExists(dest) Then
			fs.CreateFolder dest
			End If
		fs.MoveFile path, dest
		filesmoved = filesmoved & Right(ImageFileName,12) & vbCr
		end if
	Next
If filesmoved <> "" then
	MsgBox "Moved the following Images" & vbCR & filesmoved, vbInformation
	end if

Set fs = Nothing
 
Thanks for that Apple, looks like a good start. Might add it as a scheduled task in XP so it does it automatically.

Cheers.
 
I use the following PHP script I wrote on my Linux box, once in a while:
PHP:
#!/usr/bin/php5 -q
<?php
// User input function.
function read() {
    $fp = fopen('/dev/stdin', 'r');
    $input = fgets($fp, 255);
    fclose($fp);
    return(str_replace("\n", '', $input));
}

// Month-str to month-num.
$months = array(
    'Jan' => '01',
    'Feb' => '02',
    'Mar' => '03',
    'Apr' => '04',
    'May' => '05',
    'Jun' => '06',
    'Jul' => '07',
    'Aug' => '08',
    'Sep' => '09',
    'Oct' => '10',
    'Nov' => '11',
    'Dec' => '12'
);

// Get the input filename.
$args = $_SERVER['argv'];
$file = (!$args[1]) ? $file = read() : $args[1];
if (strlen($file) == 0 || !file_exists($file)) exit("Invalid input.\n");

// Split filename and type.
$file_p = strrpos($file, '.');
$file_t = substr($file, $file_p);
$file_n = substr($file, 0, $file_p);

// Temporary date holder.
$date_t = '';

// Open the input file and loop through each line.
$fi = fopen($file, 'r');
while (!feof($fi)) {
    $line = fgets($fi);

    // If line is blank, then skip it.
    if (strlen(trim($line)) == 0) continue;

    // Isolate the date/time part of the line.
    $date_b = strpos($line, '[')+1;
    $date_e = strpos($line, ']', $date_b);
    $date_r = substr($line, $date_b, $date_e - $date_b);

    // Split up the date
    $date_a = explode(' ', $date_r);
    $date = $date_a[4] . $months[$date_a[1]] . $date_a[2];

    // If the date has changed, close the current output file and open a new.
    if ($date != $date_t) {
        if ($fo) fclose($fo);
        $date_t = $date;
        $fo = fopen($file_n . '-' . $date . $file_t, 'a');
    }
    fwrite($fo, $line);
}
if ($fo) fclose($fo);
if ($fi) fclose($fi);
?>