M MY Multiplayer: Wiki
Side
Kind

onDebugMessage

ServerEventCancellable

Fired on the server for every script line that goes to the log: errors, warnings and messages.

addEventHandler("onDebugMessage", root, function(string message, int level, string|nil file, int|nil line) … end)

Handler parameters

NameTypeDescription
messagestringThe line's text.
levelint1 error, 2 warning, 3 message (from outputDebugString with another level, print or outputServerLog).
filestring|nilThe file the line came from, or the resource's name. nil for messages.
lineint|nilThe line in the file. nil when unknown.

Source

The root element (root).

Cancelling the event keeps the line from being written. What a handler of this event writes does not fire the event again.

Example

local errors = fileCreate("errors.log")

addEventHandler("onDebugMessage", root, function(message, level, file, line)
    if level == 1 then
        fileWrite(errors, ("%s:%s: %s\n"):format(file or "?", line or "?", message))
        fileFlush(errors)
    end
end)

See also