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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Plugins
. . -> [Subject]  Logging plugin

Logging plugin

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


Posted by Lisev   Poland  (8 posts)  [Biography] bio
Date Sat 11 Dec 2004 06:23 PM (UTC)
Message
If anyone wants his/her logs put in directiories depending on the year and month. All you have to do i set default log directory in global preferences and world name in world preferences.
Here is the code:


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Friday, December 10, 2004, 9:25 PM -->

<muclient>
<plugin
   name="Logger"
   author="Lisev"
   id="c8198a528d16d91779380483"
   language="VBscript"
   purpose="Logging_mud"
   date_written="2004-12-10 21:24:03"
   requires="3.50"
   version="1.0"
   >

</plugin>

<timers>
  <timer name="reopen" script="Reopen_log" enabled="y" hour="1"></timer>
  <timer name="boot_up" script="Reopen_log" enabled="y" second="1" one_shot="1">

  </timer>
</timers>

<!--  Script  -->


<script>
<![CDATA[
option explicit


Sub OnPluginInstall
    dim path, Filename, MyFolder, MyFiles
    
    path = world.getInfo(58)
    
    Set MyFiles = CreateObject("Scripting.FileSystemObject")
    
    if len(path) < 1 then
       world.note "Global log dir was not set"
       exit sub
    end if
    

    if not(MyFiles.FolderExists(path & year(now()) & "/")) then
       world.note "Folder: " & path & year(now()) & " does not exists. I will try to create it."
       
       MyFiles.CreateFolder(path & year(now()))
       if (err.number>0) then
          world.note "Error during creation of folder: " & year(now()) & "\"
          exit sub
       else
          world.note "Folder created: " & year(now()) & "\"
          path = path & year(now()) & "\"
       end if
    else
       path = path & year(now()) & "\"
    end if
    
    MyFolder = MonthName(Month(now()))
    
    if not(MyFiles.FolderExists(path & MyFolder)) then
       world.note "Folder: " & path & MyFolder & "\ does not exist. I'll try to create it"
       
       MyFiles.CreateFolder(path & MyFolder)
       if (err.number>0) then
          world.note "Error during creation of folder: " & MyFolder & "\"
          exit sub
       else
          path = path & MyFolder & "\"
       end if
    else
          path = path & MyFolder & "\"
    end if
    
    
    world.setvariable "old_option_log_line_preamble_input", world.getAlphaOption ("log_line_preamble_input")
    world.setAlphaOption "log_line_preamble_input", "[%H:%M:%S][command] "

    world.setvariable "old_option_log_line_preamble_notes", world.getAlphaOption ("log_line_preamble_notes")
    world.setAlphaOption "log_line_preamble_notes", "[%H:%M:%S][note] "
    
    world.setvariable "old_option_log_line_preamble_output", world.getAlphaOption ("log_line_preamble_output")
    world.setAlphaOption "log_line_preamble_output", "[%H:%M:%S] "
    
    Filename = path & Replace (World.Worldname, " ", "")
    Filename = Filename & "_" & year(now()) & "_" & monthname(month(now()))

    Filename = Filename & "_" & day(now())
    Filename = Filename & ".txt"
  
  if World.OpenLog (FileName, True) = 0 then
        World.WriteLog "--- Log open: " & Now () & " ---"
        World.colournote "red", "black", "Logging enabled: " & FileName
  else
        World.colournote "red", "black", "Logging disabled (something did not worked) " & FileName
  end if    
End sub


Sub OnPluginClose
  World.colournote "red", "green", "Closing log"
  World.WriteLog "--- Log Closed " & Now () & " ---"
  World.CloseLog

  world.setAlphaOption "log_line_preamble_input",  world.getvariable("old_option_log_line_preamble_input")
  world.setAlphaOption "log_line_preamble_notes",  world.getvariable("old_option_log_line_preamble_notes")
  world.setAlphaOption "log_line_preamble_output", world.getvariable("old_option_log_line_preamble_output")
End Sub

Sub Reopen_log(timer)
  dim file
  file = world.getinfo(51)
  world.colournote "pink", "black",  "---- Reopening log in progress: " & now() & " ------"
  world.CloseLog

  if World.OpenLog (file, True) = 0 then
     world.colournote "pink", "black",  "---- Reopening of log SUCCESS: " & now() & " ------"
  else
     world.colournote "pink", "black",  "---- Reopening of log FAILURE: " & now() & " ------"
  end if    

end sub
]]>
</script>


</muclient>

[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,064 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 HostDash]