How to get commands sent to OnPluginSend into log?

Posted by Grainer on Mon 16 Mar 2026 03:36 PM — 3 posts, 2,379 views.

#0
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?
Australia Forum Administrator #1

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))
Amended on Mon 16 Mar 2026 09:06 PM by Nick Gammon
#2
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