Log¶
Server log helpers for registering log types, formatting log messages, dispatching log hooks, printing log output, and saving log entries to the database.
Overview
lia.log.addType(logType, func, category)View Source
Purpose
Registers a log type formatter and assigns it to a category.
Realm
Server
Parameters
string logType The unique log type key used when creating log entries.
function func The formatter function called by `lia.log.getString`. It receives the client followed by any extra arguments passed to the log call and should return the final log message string.
string category optional The category name associated with this log type. If the category is not a string when a log is added, it falls back to the uncategorized label.
Returns
Example Usage
lia.log.addType("customAction", function(client, targetName)
return client:Name() .. " performed a custom action on " .. targetName
end, L("admin"))
lia.log.getString(client, logType)View Source
Purpose
Builds a formatted log message and retrieves the category for a registered log type.
Realm
Server
Parameters
Player client optional The player associated with the log entry, if one exists.
string logType The registered log type key to resolve.
Returns
string|nil The formatted log message when the log type exists and its formatter succeeds. string|nil The category assigned to the log type when the formatter succeeds.
Example Usage
local logString, category = lia.log.getString(client, "charLoad", character:getName())
lia.log.add(client, logType)View Source
Purpose
Creates a server log entry for a registered log type, emits the log hook, prints the entry to the server console, and saves it to the database.
Realm
Server
Parameters
Player client optional The player associated with the log entry, if one exists.
string logType The registered log type key used to generate the entry.
Returns
Example Usage
lia.log.add(client, "chatOOC", message)
Hooks
Library-specific hooks documented for this library.
OnServerLog(client, logType, logString, category)View Source
Purpose
Called after a log string has been generated and before the entry is printed to the server console and inserted into the database.
Realm
Server
Parameters
Player client optional The player associated with the log entry, if one exists.
string logType The registered log type key used to generate the entry.
string logString The formatted log message that will be printed and stored.
string category The resolved category name for the log entry.