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
| Name | Type | Description |
|---|---|---|
| message | string | The line's text. |
| level | int | 1 error, 2 warning, 3 message (from outputDebugString with another level, print or outputServerLog). |
| file | string|nil | The file the line came from, or the resource's name. nil for messages. |
| line | int|nil | The 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)