[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]  Bug reports
. . -> [Subject]  Multiple problems with OpenLog
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Multiple problems with OpenLog

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


Posted by Vincitore   (11 posts)  [Biography] bio
Date Wed 23 Feb 2011 11:48 PM (UTC)
Message
I'm trying to create an alias to open a log, get some information, and close the log. It doesn't work, though, although there's no problem with opening the log manually--just with OpenLog.

Here's an alias I wrote for testing:
OpenLog ("test.txt", true)
Note(IsLogOpen())
SetLogOutput (true)
Note(GetLogOutput ())
SetLogInput (true)
Note(GetLogInput ())
Send ("do look,hop")
WriteLog("--- Message for the log file ---")
CloseLog()
FlushLog()

And here's what it appends to test.txt:
true
true
true
--- Message for the log file ---

I see the output for "do look,hop" in the game window, but it isn't appended to the file.

Also, OpenLog ignores the chosen log directory. In XP it would save stuff in the Start Menu folder, for some reason, and in Windows 7 it saves in C:\Mushclient. Trying to set a relative or absolute path fails entirely; I get "false" for IsLogOpen. I don't really care about this part, since I can figure out where to find the files... but not being able to log game output (unless I manually open the log) is a pain. Is this a problem with OpenLog or with something I'm doing?
[Go to top] top

Posted by Nick Gammon   Australia  (21,675 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Thu 24 Feb 2011 01:13 AM (UTC)
Message
Well let's see...


  • If you don't specify a path name it opens files in the "current directory" whatever that is. You might want to try:

    
    OpenLog (GetInfo (58) .. "test.txt", true)
    


    Where GetInfo (58) is the default log files directory.

  • You need to flush the log before closing it. Once it is closed it can't be flushed. However closing flushes it anyway. The idea of flushing is to force out half-filled blocks in case of a crash, so you might do that every 5 minutes or so.

  • Your script executes completely before MUSHclient processes more input. Thus it may have sent "do look,hop" to the MUD, but it hasn't got the reply back yet. And then you closed the log file before it did.

- Nick Gammon

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

Posted by Vincitore   (11 posts)  [Biography] bio
Date Reply #2 on Thu 24 Feb 2011 10:51 PM (UTC)

Amended on Fri 25 Feb 2011 12:55 AM (UTC) by Vincitore

Message
Right on all accounts! Changing it as follows, all behaviors are as expected.
require "wait"
wait.make (function ()
    OpenLog (GetInfo (58) .. "test.txt", true)
    Note(IsLogOpen())
    SetLogOutput (true)
    Note(GetLogOutput ())
    SetLogInput (true)
    Note(GetLogInput ())
    Send ("do l,hop")
    WriteLog (os.date ("%d %b %y %I:%M %p"))
wait.time (1)
    CloseLog()
    Note "Log closed."
end)
[Go to top] top

Posted by Baatti   USA  (7 posts)  [Biography] bio
Date Reply #3 on Sun 17 Apr 2011 09:56 PM (UTC)
Message
I'm having a problem with logging from a plugin, using OpenLog().

I have this trigger:

<triggers>
 <trigger
  enabled="y"
  match="^$"
  omit_from_log="y"
  omit_from_output="y"
  regexp="y"
  sequence="100"
 >
 </trigger>
</triggers>


This trigger's job is to gag blank lines after every prompt. If I use: FILE>LOG SESSION this trigger works, i.e. no blank lines show up in my log file.

However when I initiate a logging session via OpenLog(), I'm logging all of my blank lines.
[Go to top] top

Posted by Nick Gammon   Australia  (21,675 posts)  [Biography] bio   Forum Administrator
Date Reply #4 on Sun 17 Apr 2011 11:08 PM (UTC)
Message
I don't see why that should happen. Once the log file is open, logging is done the same way, regardless of how you opened it.

- Nick Gammon

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

Posted by Vincitore   (11 posts)  [Biography] bio
Date Reply #5 on Mon 18 Apr 2011 12:56 AM (UTC)
Message
The solution to my path problem was to stop trying to use backslashes. Forward slashes work, as though the file path were an internet address. Odd, but easy enough to deal with once the issue is known.
[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.


4,014 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]