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

Records a log entry and prints it to the console in the given color, prefixed with the action.
Records a log entry and shows the message to every player as a notification.
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.
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).
Pushes a message to every Discord webhook registered for the given type.

Methods

Log:colored(color, message, action, object, subject)

shared packages/flow/models/log.lua:114

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 nil type of the logged event
  • object String/Number optional, defaults to nil who or what performed the action
  • subject String/Number optional, defaults to nil who or what the action was performed on

Returns

  • Log the Log class, for chaining

See also

Log:notify(message, arguments)

shared packages/flow/models/log.lua:132

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

Log:print(message, action, object, subject)

shared packages/flow/models/log.lua:81

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 nil type of the logged event
  • object String/Number optional, defaults to nil who or what performed the action
  • subject String/Number optional, defaults to nil who or what the action was performed on

Returns

  • Log the Log class, for chaining

See also

Log:replicate(condition)

shared packages/flow/models/log.lua:145

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 nil called with each Player; return true to send the entry to them. Everyone receives it when omitted

Returns

  • Log the Log class, for chaining

Log:to_discord(webhook_type, message)

shared packages/flow/models/log.lua:58

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 nil text to push; defaults to the last message given to Log:write

Returns

  • Log the Log class, for chaining

Log:write(message, action, object, subject, io)

shared packages/flow/models/log.lua:21

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 nil type of the logged event; stored in snake_case
  • object String/Number optional, defaults to nil who or what performed the action, e.g. a user ID
  • subject String/Number optional, defaults to nil who or what the action was performed on
  • io Function optional, defaults to nil outputs the entry; called with (message, action in CamelCase, object, subject)

Returns

  • Log the Log class, for chaining

Defined in