Limit Log file to a certain size

Posted by Welcomb on Tue 29 Apr 2003 09:40 AM — 16 posts, 56,300 views.

#0
I log the world activity in html and it could grow to be over 50MB in a few days if there has been a lot of activity. It would be good if there's a feature to limit the log size to a user-defined value such that the log will just keep overwritting the old data in the event the max size is reached.
Greece #1
That would be a bit hard to do, and not really necessary, in my opinion... Just recycle the logs, rename them to the current date/time and zip them... a 50 MB log can zip down to 2-3 MB or so... Also, why log to HTML if you're going to delete old data anyway? I only log important events to HTML, all others in plaintext...
Australia Forum Administrator #2
I'm inclined to agree that it would be better to close and reopen under a different name every 12 hours or so, rather than just overwriting when it happened to fill up, which might be in the middle of an important session. Then you could either delete or zip up the old copies.

You could make a timer that did something like this:

world.CloseLog
world.OpenLog "mylogfile " & Replace (Replace (Now, "/", "-"), ":", "."), 0

What that would do is get the current date and time and replace slashes and colons with dashes and dots (to get a valid file name) and then open that file.

Set the timer to go off every 12 hours or so, and you should be right.
Greece #3
God, Nick, you really need to get the scripting documentation part of the forum in a HTML help file, i didn't even know about those commands!
USA #4
Theyre part of VBscript, you can download documentation from the VB section of the forum (a link above it, windows scripting help, or something of the like), that current one includes VBSript, and JavaScript, as well as RegExp, And some other things (FSO, etc)
USA #5
Nope. Those commands are not VBScript, there are Mushclient internals. As for HTML help... MS HTMLHelp sucks imho, since it is heavilly based off IE and is prone to try to establish a connection to the net if you try to load .html files in it. I have also seen it do the same thing with certain .chm files that 'refer' to .html documents in some cases. This behaviour is, at least for me, stupid and inconvenient, since the idea of a bloody help file is to not have to go online to get information. But I do agree that the existing help is now so far out of date that it almost isn't worth having.
Australia Forum Administrator #6
Improving the help is next on the major list of things to do.

It probably needs a complete rewrite, which won't be quick.
USA #7
Replace and Now, are VBscript commands, Open and Closelog are Mushclient commands, But theyre already documented, so I assumed He wasnt referring to thsoe.
Australia Forum Administrator #8
There is a world.Replace command in the MUSHclient scripting language, however if you leave off "world" you probably get the VBscript one.
Greece #9
I was referring to the log commands, i know that replace is a vbscript function :) Anyway, my point was not so much to the .chm file, just make the documentation available offline somehow... I assumed that a .chm would be the easiest to do, since you just point to the index file and the rest is compiled automatically. It does suck, i know, but it's better than reading html files manually :p
USA #10
I just made the webpage availiable offline (the one with the scripting info), Set the depth to 1 or 2 links, and let it do its thing... Oddly enough though, it didnt get all of the functions, but it did work for most of them.
Australia Forum Administrator #11
If you bring up the full list first (ie. search with a blank search string) it should return all functions, then making it available offline should find them all.

Maybe, if you didn't do that, the ones that missed out were not cross-referenced anywhere.
#12
Ok i made the script to write a new log file for every session using the code you posted. However it writes the file to my desktop! Is there any way to specify a default log directoy to the one in the MUSHClient folder? the one under Golbal Perference don't seem to work.
Australia Forum Administrator #13
The word "mylogfile" was supposed to imply "whereever you want to put it".

Either put in the full pathname yourself, or use world.GetInfo to find the log file directory.

eg.

Solution 1:

world.OpenLog "c:\mushclient-logs\mylogfile " & Replace (Replace (Now, "/", "-"), ":", "."), 0

Solution 2:

world.OpenLog world.GetInfo (58) & "mylogfile " & Replace (Replace (Now, "/", "-"), ":", "."), 0
#14
Thanks. I got what you mean. Got it working now
Australia Forum Administrator #15
Of course, it would help to put .txt at the end, like this:


world.OpenLog world.GetInfo (58) & "mylogfile " & Replace (Replace (Now, "/", "-"), ":", ".") & ".txt", 0