[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  VBscript
. . -> [Subject]  How do I make a timer do this...
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

How do I make a timer do this...

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Weston   (28 posts)  [Biography] bio
Date Wed 26 May 2004 12:38 AM (UTC)
Message
http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=4192

The URL shown above is where this started.
My question is:

How do I make a timer that would check the filesize of the current log file every hour and then close and re-open that log file if it is 500 kilobytes or larger.

By 'close and re-open' I mean close/end the current log file, and open/begin a new log file for the data past that 500 kilobytes limit.
[Go to top] top

Posted by Nick Gammon   Australia  (21,677 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Wed 26 May 2004 01:07 AM (UTC)
Message
You reminded me just in time. :)

I have added a new selector to world.GetInfo which returns the size of the current log file.

Thus, you want a timer that (say every hour) does this:


if GetInfo (231) > 500000 then
  CloseLog
  OpenLog "", 0
end if


You need version 3.50 onwards to do this.

The OpenLog with an empty filename will take the file name defined in the logging configuration window, which will need to have the date/time in it to avoid overwriting the same file each time.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Weston   (28 posts)  [Biography] bio
Date Reply #2 on Wed 26 May 2004 06:48 PM (UTC)
Message
That sounds pretty cool, but how do I get version 3.50?
The website only mentioned version 3.45.

Is there a way to get a similar function with version 3.45?
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Reply #3 on Wed 26 May 2004 07:06 PM (UTC)
Message
Version 3.50:
http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=4248&page=999999

Nick only updates the main page once releases have a signifigant change, as well as have been bug tested. Mentality is if youre on the forums, you wont just give up when something goes wrong (because youre more than just a normal user). So rather than have a bunch of people with broken clients, its just us.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
[Go to top] top

Posted by Weston   (28 posts)  [Biography] bio
Date Reply #4 on Sun 30 May 2004 10:05 PM (UTC)
Message
That's pretty cool.
Thanks for explaining that to me, Flannel.

I'll go get 3.50 now and try out the new selector.
[Go to top] top

Posted by Weston   (28 posts)  [Biography] bio
Date Reply #5 on Sat 19 Jun 2004 08:44 PM (UTC)
Message
I am noticing a problem...

I created a timer that repeats ever 30 minutes, in the "Send:" area I pasted (replacing 500000 with 2000000)


if GetInfo (231) > 2000000 then
CloseLog
OpenLog "", 0
end if


It works, but the new log file isn't being created. When the timer fires and the log file is over 2,000,000 bytes, that file is closed, but a new file isn't begin and so logging ends. I have to click the "Log Session" button on the toolbar to start the logging again.

Any guesses on what's wrong?
[Go to top] top

Posted by Nick Gammon   Australia  (21,677 posts)  [Biography] bio   Forum Administrator
Date Reply #6 on Sat 19 Jun 2004 09:29 PM (UTC)
Message
Do you have a log file name in the logging configuration area? The OpenLog with no filename will not work unless you do.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Weston   (28 posts)  [Biography] bio
Date Reply #7 on Tue 22 Jun 2004 02:42 AM (UTC)
Message
When you say, "file name in the logging configuration area" do you mean the 'Logging configuration area' that is under 'General'?

I do already have a file name in the 'Automatically log to this file:' field.


Did I did interpret your question correctly?
[Go to top] top

Posted by Nick Gammon   Australia  (21,677 posts)  [Biography] bio   Forum Administrator
Date Reply #8 on Tue 22 Jun 2004 04:11 AM (UTC)
Message
Yes, you did. Oops, you found a bug in the OpenLog routine.

OpenLog with an empty file name will not work as documented.

As a work-around until the next version supply your own file name (eg. the log file with the date/time manually inserted into it).

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Poromenos   Greece  (1,037 posts)  [Biography] bio
Date Reply #9 on Tue 22 Jun 2004 07:19 AM (UTC)
Message
It would be nice if you released bugfix releases if bugs were found, like 3.50 build whatever or something like that. It's annoying to have to live with a bug :( Unless you have the next version half-written and you have to release the bugfix, that would be a bit of a hassle... Are you using a CVS? You could just branch and fix the bug without losing the current version.

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
[Go to top] top

Posted by Weston   (28 posts)  [Biography] bio
Date Reply #10 on Thu 24 Jun 2004 03:24 AM (UTC)
Message
Does the bug mean that OpenLog can not expand the date/time/hour variables used in the Logging configuration either?

I first tried to use:


if GetInfo (231) > 500000 then
CloseLog
OpenLog "MUD log %b %d %Y (%H %M).htm", 0
end if


That didn't work. It seems like when I hit 2MB, the logging stopped, and no new file was started. Then I tried to use:


if GetInfo (231) > 500000 then
CloseLog
OpenLog "C:\Program Files\MUSHclient\logs\MUD log %b %d %Y (%H %M).htm
end if


That gave me a file which was named "MUD log %b %d %Y (%H %M).htm".



Supplying a filename like OpenLog "MUD log (2)" might be good, but won't the filename that I specify be overwritten each time? Since I am unable to use the %b %d %Y (etc.) variables that I usually use.
[Go to top] top

Posted by Nick Gammon   Australia  (21,677 posts)  [Biography] bio   Forum Administrator
Date Reply #11 on Thu 24 Jun 2004 10:07 PM (UTC)
Message
Yes, I am saying that OpenLog will not expand variables. If it did I would have suggested what you have tried. For now, use some VBscript date functions to manually insert the relevant parts of the date.

For example, the VBscript DatePart function (which breaks dates up into the component parts) combined with Now, should do it.

For example, this gives the day:

/world.note DatePart ("d", Now)

To save you looking it up, here are the other letters you can use:

yyyy Year
q Quarter
m Month
y Day of year
d Day
w Weekday
ww Week of year
h Hour
n Minute
s Second


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Weston   (28 posts)  [Biography] bio
Date Reply #12 on Sat 26 Jun 2004 03:57 PM (UTC)
Message
I feel really stupid asking this since it seems like I'm suppose to know what do at this point, uhm, but I don't.

How do I modify the existing:


if GetInfo (231) > 2000000 then
CloseLog
OpenLog "", 0
end if


...to use the VBscript DatePart?
[Go to top] top

Posted by Nick Gammon   Australia  (21,677 posts)  [Biography] bio   Forum Administrator
Date Reply #13 on Sun 27 Jun 2004 10:33 PM (UTC)
Message
It depends how you want your file name formatted, but something like this.

Replace: OpenLog "", 0 by:


OpenLog "MyLogFile " _
        & DatePart ("h", Now) & ":" _
        & DatePart ("n", Now) & " " _
        & DatePart ("d", Now) & "-" _
        & DatePart ("m", Now) & "-" _
        & DatePart ("yyyy", Now) & " " _
        & " log.txt", 0


This will open a log file like:

MyLogFile 14:22 28-6-2004 log.txt

The DatePart sections are pulling various numbers out of the date (hour, minute, day, month, year) and adding them into the file name.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


7,030 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]