Delayed Logging

Posted by Vchat20 on Thu 12 Oct 2006 02:29 AM — 3 posts, 13,410 views.

USA #0
So yeah. I have recently been converting my MUSHing systems to using mushclient simply because of its overall flexibility totally owning simplemu which is what I have been using before this point.

Now I have a server machine running here which coincidentally runs on a 24/7 basis. As such I have been using SimpleMU and stay connected to my MUSH and it takes care of logging every single thing on the MUSH for me so if anything does happen to go wrong or something of that sort, I can go back and look in logs. Part of that is ive got a scheduled batch script to copy the log file to a different directory, timestamp it, and wipe said log file clean for simplemu to continue about its business.

NOW to the point. I have got this set up in MC right now, but my biggest miff is MC seems to delay posting the new lines on the MUSH to the log by quite a bit of time. Whereas Simplemu was pretty much *snap fingers* instant. Is there something im missing here maybe? Any help would greatly be appreciated. Thanks.
Australia Forum Administrator #1
Most operating systems cache up disk file data into a sector (possibly 512 bytes) before writing it, for efficiency.

This could account for the delays in the log being updated if you read it into another application.

I have added a new script funcion - FlushLog - to version 3.82.

If you want to have the log updated quickly, get that version (when it is released) and make a timer that does "FlushLog ()" every second or so.
USA #2
It's possible that SimpleMU opens the log file for append, writes the log stuff, and then closes it immediately. That would explain why it's "instant". I imagine that Nick doesn't open/close the file all the time, for efficiency, and as a result Windows doesn't get around to writing to disk until the buffer is of a reasonable size.

The advantage to the SimpleMU method is that it's "instant", and doesn't lock the log file. Nick's method is more efficient for disk writes.

Nick, I'm not sure what IO method you're using, but I think that C++ streams have a flag you can set such that they don't buffer output and instead flush immediately. Perhaps that could be a checkbox option if people cared, assuming it's as easy as I believe C++ streams make it. But the timer option is also perfectly fine. It's probably a specialized enough problem where you don't need an option for everyone (since relatively few people will care).