Log entries, stored in the logs table of the database.
The class methods record an entry and output it in one go: Log:print and
Log:colored write to the console, Log:notify notifies every player, Log:to_discord
pushes the last message to Discord webhooks and Log:replicate repeats the last
entry on the clients. They return the class, so the calls can be chained.
Summary
Methods
Methods
Records a log entry and prints it to the console in the given color, prefixed with the action.
Log:colored(
command_log_color,
message,
'PlayerRunCommand',
IsValid(actor) and actor.record.id or 'console'
):replicate(function(listener)
return listener:is_staff() and listener:can(cmd_table:get_permission())
end)
Parameters
- color Color color of the console output
- message String text of the entry
- action String optional, defaults to
niltype of the logged event - object String/Number optional, defaults to
nilwho or what performed the action - subject String/Number optional, defaults to
nilwho or what the action was performed on
Returns
- Log the Log class, for chaining
See also
Records a log entry and shows the message to every player as a notification. Server only.
Parameters
- message String text or language phrase of the notification
- arguments Map arguments of the phrase; its action, object and subject fields are used for the log entry
Returns
- Log the Log class, for chaining
Records a log entry and prints it, prefixed with the action, to the server log on the server or to the console on the client.
Parameters
- message String text of the entry
- action String optional, defaults to
niltype of the logged event - object String/Number optional, defaults to
nilwho or what performed the action - subject String/Number optional, defaults to
nilwho or what the action was performed on
Returns
- Log the Log class, for chaining
See also
Sends the most recent entry to the clients, where it is handled the same way it was made: an entry of Log:print or Log:colored is printed to the console, and an entry of Log:write or Log:notify is only recorded, with no output of its own (the LogReplicate hook still runs for it). Does nothing if the most recent entry has already been sent. Server only.
Parameters
- condition Function optional, defaults to
nilcalled with each Player; return true to send the entry to them. Everyone receives it when omitted
Returns
- Log the Log class, for chaining
Pushes a message to every Discord webhook registered for the given type. Does nothing on the client.
Parameters
- webhook_type String optional, defaults to
'all'webhook type - message String optional, defaults to
niltext to push; defaults to the last message given to Log:write
Returns
- Log the Log class, for chaining
Records a log entry. On the server the entry is saved to the logs table. The entry is also remembered so that it can be passed on with Log:replicate.
Parameters
- message String text of the entry
- action String optional, defaults to
niltype of the logged event; stored in snake_case - object String/Number optional, defaults to
nilwho or what performed the action, e.g. a user ID - subject String/Number optional, defaults to
nilwho or what the action was performed on - io Function optional, defaults to
niloutputs the entry; called with (message, action in CamelCase, object, subject)
Returns
- Log the Log class, for chaining