Logging commands send via World.Send

Posted by Magnum on Sat 23 Feb 2002 08:09 AM — 9 posts, 39,742 views.

Canada #0
I've noticed that commands sent via World.Send do not get put in the log. (Everything under log in options is checked except HTML)

Is there a way to log commands sent via "World.Send"?

Perhaps it has something to do with my script turning echo off on occasion. Although I don't want commands to echo to the screen, I still may want them logged).
Australia Forum Administrator #1
I suppose that should be an option? Anyway, use world.WriteLog to log anything you want to.
Canada #2
Yes, make it an option please.

For the moment, I can't be bothered to go through my 1800 line script and add a world.writelog command to match every world.send I do. I am not sure I want to do that anyway, just because it would make my script that much bulkier.
Australia Forum Administrator #3
I have added that as suggestion #448.
#4
In the meantime, you might consider writing a small function that takes a text argument and does both a world.send and a world.WriteLog. Then just search through your script for world.sends and replace them with your new function. This might even be nicer for you, since you could put a generic signal to yourself that the text being logged is from your own scripts.
#5
LogInput sounds (to me) like it should do this for you. Doesn't work for me though.

http://www.mushclient.com/scripts/function.php?name=LogInput&searchfor=

Canada #6
Not a bad solution, Dubtach. It should work well for anyone else with this problem.

I realized that the main commands I wanted to log were skill\spell commands. Since they are ALL sent through my spell queue, it's a simple matter to add a single World.WriteLog command within the spell queue code.

At least half of the other World.Send's in my script are "party tell"s. Since I see what I said echoed back to me from the mud, I don't care to see the outgoing command as well ...So I turn echo off during World.Send, and I don't care if these don't get logged.
Australia Forum Administrator #7
Strictly speaking, "commands" are things you type.

Text sent via world.send is not considered a command.

This is a semantic point, but is the reason it doesn't work right now. When the option is added in a future version you can choose whether world.send is logged.
USA #8
Put this in your script file:

Sub LoggedSend(sText)
    World.Send sText
    World.WriteLog sText
End Sub

Then simply search-and-replace all occurrences of "World.Send" with "LoggedSend".

This approach is far better than simply wedging an extra line next to every world.send in your script file, and allows you the flexibility to change how this is handled at any time in the future.

Say you suddenly want to check to be certain the log is open before writing to the log: Just edit the definition of LoggedSend:

Sub LoggedSend(sText)
    World.Send sText
    If World.IsLogOpen Then
        World.WriteLog sText
    End IF
End Sub

If you're not already using subroutines and functions extensively in your code, you're just making things harder on yourself when it comes to maintenance.