Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ Logging chat world sessions automatically

Logging chat world sessions automatically

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


Posted by Hinotori   (5 posts)  Bio
Date Thu 30 Aug 2007 02:58 AM (UTC)
Message
Hi there, I'm a relatively new user, and I have a question regarding logging chats sent to closed worlds. I used the example that Nick Gammon graciously provided in the FAQ, and so far it has been working excellently. However, one thing that I would like to do is have each chat world log sessions automatically, appending received chats to their own log. Unfortunately, because each world is permanently disconnected, they never begin logging sessions automatically, even when automatic logging is set in their world settings.

This issue may seem minor, but given that I have 4-6 chat worlds open at the same time, it is a bit tedious to have to manually click the "log session" button for each one every time I start the client up.

If there's a way to force each window to log sessions automatically, I'd like to know. If not, then some help on how to append text received in the chat world to a text file would be appreciated. Thanks a lot!
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Thu 30 Aug 2007 06:15 AM (UTC)

Amended on Thu 30 Aug 2007 06:17 AM (UTC) by Nick Gammon

Message
Save this plugin (between the lines) and install into each of your "logging" worlds. (In other words, copy and paste into a text file, save as AutoLogger.xml, and then use File -> Plugins to install it). That will open a log file as the world is opened (ie. when the client starts up, if you are automatically opening them).


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Friday, August 31, 2007, 4:09 PM -->
<!-- MuClient version 4.15 -->

<!-- Plugin "AutoLogger" generated by Plugin Wizard -->

<muclient>
<plugin
   name="AutoLogger"
   author="Nick Gammon"
   id="46397de5db3216159f692896"
   language="Lua"
   purpose="Opens a log file when the world is opened"
   date_written="2007-08-31 16:03:25"
   requires="4.00"
   version="1.0"
   >

</plugin>


<!--  Script  -->


<script>
<![CDATA[
function OnPluginInstall ()
  OpenLog (GetInfo (58) ..   -- log files directory
           GetInfo (2) ..    -- world name
           os.date ("-%a-%b-%d-%Y-%H-%M.txt"), -- date and time
           true)  -- append to existing log of same name
end -- OnPluginInstall 

]]>
</script>

</muclient>



The work is done in OnPluginInstall - this simply opens the log file, using the log files directory (which you specify in the Global Preferences, appends the world name (so you can distinguish each one), and then appends the date and time. In my test I got this log file name:


C:\Program Files\MUSHclient\logs\SMAUG-Fri-Aug-31-16-13.txt


You simply have to change the os.date function call to modify the way the file name appears.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Hinotori   (5 posts)  Bio
Date Reply #2 on Thu 30 Aug 2007 10:32 AM (UTC)
Message
Thanks Nick, especially for the fast reply.

This is close to what I want, but I noticed that it's now creating a new file for each session. Is it possible to modify the plug-in in such a way that it continuously appends sessions to the same log file (possibly with a header signifying the date and time of each session)?

I'm sorry for not yet being competent enough with the coding to deduce a solution by looking at the plug-in by itself.

Thanks again.
Top

Posted by Shaun Biggs   USA  (644 posts)  Bio
Date Reply #3 on Thu 30 Aug 2007 10:56 AM (UTC)

Amended on Thu 30 Aug 2007 10:57 AM (UTC) by Shaun Biggs

Message
Just change the script to something like this then.
function OnPluginInstall ()
  OpenLog (GetInfo (58) .. -- log files directory
           GetInfo (2),    -- world name
           true)  -- append to existing log of same name
  WriteLog ( os.date ("New Session at %a-%b-%d-%Y-%H-%M"), -- date and time )
end -- OnPluginInstall

It is much easier to fight for one's ideals than to live up to them.
Top

Posted by Hinotori   (5 posts)  Bio
Date Reply #4 on Thu 06 Sep 2007 11:56 AM (UTC)
Message
I apologize that this response is a bit late.

Thank you, Shaun; that code was very helpful.

There was a slight problem with getting that code to work at first. But after looking at it for a bit, I figured out the problem: the comment "date and time" needed to be moved outside the parenthesis. I also figured out that GetInfo(51) appended logged text to the world's log file rather than sending them to the default directory. Here is the final revised section after working with it, in case anyone else wants to use it:


function OnPluginInstall ()
OpenLog (GetInfo (51), -- log files directory
true) -- append to existing log of same name
WriteLog ( os.date ("New Session at %a-%b-%d-%Y-%H-%M"))-- date and time
end -- OnPluginInstall



Thanks again you two.
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.


16,207 views.

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

Go to topic:           Search the forum


[Go to top] top

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