Log file tricks

Posted by Poromenos on Sat 20 Sep 2003 09:16 PM — 6 posts, 21,472 views.

Greece #0
OK, hmm, this is what I want to do. I have MC log the output of the MUD in an .html file and have an http server point at it, so that people can see what i am doing (I call it MudTV :P). I am having 2 problems:
1) MC only updates the logfile in intervals, or when it gets enough data. Is there a way that i can forcefully update the logfile, like calling LogClose and OpenLog whenever a line comes in?
2) I need to limit the buffer, because it can get very large very fast, and if 2-3 people are looking at it (it refreshes, too) my connection is lagged a lot. Is there a way to make it write the last X lines? What i'm thinking is something like a timer that writes the last X lines to a file, possibly omitting built-in logging, but wouldn't that log in plaintext only? How can i do that and log in HTML?
Any help would be appreciated, i don't need the entire script :p
Greece #1
I tried doing a:
CloseLog
OpenLog "I:\Exp\Xitami\webpages\feed\index.html", True
But the log won't open, the log button on the bar is still disabled.
Australia Forum Administrator #2
Quote:

What i'm thinking is something like a timer that writes the last X lines to a file, possibly omitting built-in logging, but wouldn't that log in plaintext only? How can i do that and log in HTML?


You could make that timer write in HTML easily enough.

For a start, check out:

http://www.gammon.com.au/scripts/doc.php?function=FixupHTML

This lets you convert < and > characters into &lt; and &gt; etc. which will fix up obvious problems in trying to write HTML. Then you would need a suitable HTML header (the log file generation supplies one) with <pre> and <code> tags, thus preserving formatting.

With only a couple of lines of code you could do an HTML log that writes a black-and-white log in HTML. If you want to preserve colours it will be harder, but check out the ANSI log plugin for a method of "walking" the style runs for each line. You could modify that to output the correct colour codes each time a style colour changed.
Greece #3
Right now it's not even opening the logfile though...
Australia Forum Administrator #4
I meant by opening your own text file - there are examples here somewhere.
Greece #5
Bump! If anyone's interested, I've created a program that will allow you to stream your MUD connection to other users in real time (i.e. they will see what you see) with a minimal bandwidth hit (I can stream 30-40 connections with my 56k modem). The program is called Snoop, it's on the downloads page of www.poromenos.org and there's a tutorial at the wiki.