π Global Audit Logging System
XR-MDT includes a robust, centralized logging system designed to track every critical action performed within the tablet. This ensures accountability and provides a clear audit trail for server administrators.π How it Works
The logging system operates on a dual-path architecture:- Database Persistence: Every log is stored in the
mdt_logstable for long-term historical review. - Real-time Webhooks: Logs are immediately forwarded to configured Discord channels based on the action type and faction, separated into administrative and operational webhooks.
AddLog function is implemented in server/sv_logs.lua and is exposed as a server-side export.
π οΈ Usage for Developers
Trigger logs from any server-side script using theAddLog export.
Export Signature
What Gets Logged Automatically
TheAddLog function automatically resolves and stores:
citizenidβ fromBridge.GetCitizenIdFromObject(player).nameβ"firstname lastname"fromBridge.GetCharInfo(player).rankβ playerβs current job grade name.
Database Schema (mdt_logs)
Examples
βοΈ Configuration
Webhooks are configured inconfigs/config.webhook.lua.
Webhook Routing Priority
The system routes logs based on the action type and its destination mapping:- Routing Mapping: The action type is resolved against
Config.Webhooks.Routing. It returns:"admin"β Administrative events (hiring, firing, code changes, deletions)."faction"β Operational/faction events (fines, reports, armory)."both"β Dispatched to both administrative and operational channels.- If not zmapowany, default is
"faction"(defined as["Default"] = "faction").
- Override Checks (debugType): Checks if a specific override webhook exists under
Config.Webhooks.Types[debugType]. If set, it will override the faction webhook. - Specific Faction Webhooks:
- Operational logs: routes to
Config.Webhooks.Jobs[JOB_UPPERCASE].Faction, then falls back toConfig.Webhooks.FactionMain. - Administrative logs: routes to
Config.Webhooks.Jobs[JOB_UPPERCASE].Admin, then falls back toConfig.Webhooks.AdminMain.
- Operational logs: routes to
- Main Webhook: Final fallback to
Config.Webhooks.Mainif any of the above paths are empty or not configured.
Example Webhook Configuration Structure
π₯οΈ NUI Log Viewer
Authorized employees can view logs directly within the MDT:- Navigate to the Logs tab in any tablet.
- Logs are fetched via a server callback returning the last 200 entries for the job.
- Search by name, action type, or details.
- Filter results in real-time.
[!NOTE]
By default, the Logs tab is visible to higher ranks. Permissions are controlled via logs_view = true in the respective Grades tables.
Β© XR-Core Systems | Professional FiveM Resources
