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 ➜ Plugins ➜ How to get commands sent to OnPluginSend into log?

How to get commands sent to OnPluginSend into log?

You need to log onto the forum to reply or create new threads.

  Refresh page


Posted by Grainer   (2 posts)  Bio
Date Mon 16 Mar 2026 03:36 PM (UTC)
Message
Hi,

My MUD recently changed to UTF-8 and I'm using a modified version of the plugin from https://www.gammon.com.au/forum/?id=14283 to play.

The OnPluginSend function is the following:


function OnPluginSend (sText)
    assert (package.loadlib ("luaiconv.dll", "luaopen_iconv")) ()
    local cd = iconv.open("UTF-8", "ISO-8859-1")
    local nstr, err = cd:iconv(sText)
    Send ((nstr))
    return false
end -- OnPluginSend


In logging settings I have checked all three options (Log Output, Log Commands, Log Notes) in What to log section but my commands do not appear in the log. If I disable the plugin they do appear, but then umlaut and other non-english characters don't show correctly.

I've tried adding WriteLog command to the function or replasing the Send with LogSend but neither results in command being logged. I'm using Mushclient 5.06 through Wine.

The MUD output lines are being logged just fine but I'd like also my commands to be logged. Is there a way to get them into the log and have UTF-8 work properly?
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Mon 16 Mar 2026 09:05 PM (UTC)

Amended on Mon 16 Mar 2026 09:06 PM (UTC) by Nick Gammon

Message

Can you please wrap the WriteLog call inside the check function? That will report if the call fails (eg. log file not open). eg.

check (WriteLog (sText))

- Nick Gammon

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

Posted by Grainer   (2 posts)  Bio
Date Reply #2 on Fri 20 Mar 2026 01:18 PM (UTC)
Message
Hi Nick,

Thanks for the idea, I tried
check (WriteLog (sText))
, and also
check (WriteLog (nstr))
and neither resulted in any error code (in mud output or log) and neither got the command into log.

I did however find a workaround which doesn't seem to break anything elsewhere. I added a OnPluginSent function that'll just put the string being sent to mud into the log and it does it.


function OnPluginSent (sText)
  WriteLog ((sText))
end -- OnPluginSent
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.


885 views.

You need to log onto the forum to reply or create new threads.

  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.