JG Docs
Mechanic

Debug & Event Logging

Available in v1.7.0 and newer.

JG Mechanic now uses a central logging system. You only need to edit:

  • config/config.lua to choose where each logging category is sent.
  • config/config.webhooks.lua to add Discord webhook URLs.

Logging Categories

Logging is split into three core routes:

RouteUsed for
LOGDebug logs (can keep this off unless running into issues or asked to by support)
EVENTNormal audit logs, such as invoices, orders, tuning, shops, repairs, nitrous, and duty changes
SECURITYDenied actions, invalid values, suspicious requests, and vehicle data warnings

Configure Destinations

Set destinations in config/config.lua:

Config.Logs = {
  LOG = {
    enabled = true,
    destinations = { "console" }
  },
  EVENT = {
    enabled = true,
    destinations = { "ox_lib" }
  },
  SECURITY = {
    enabled = true,
    destinations = { "console", "ox_lib" }
  }
}

Supported destinations are:

DestinationDescription
consolePrints to the server console
ox_lib

Sends to lib.logger

Learn more: ox_lib logger documentation

discord

Sends to Discord webhooks from config.webhooks.lua

(Not recommended)

To disable a route:

Config.Logs = {
  ...
  LOG = {
    enabled = false,
    destinations = ...
  }
}

Common Examples

Use ox_lib for normal events and security logs:

Config.Logs = {
  LOG = {
    enabled = true,
    destinations = { "console" }
  },
  EVENT = {
    enabled = true,
    destinations = { "ox_lib" }
  },
  SECURITY = {
    enabled = true,
    destinations = { "ox_lib" }
  }
}

Use Discord for events, but keep security warnings in console and ox_lib:

Config.Logs = {
  LOG = {
    enabled = true,
    destinations = { "console" }
  },
  EVENT = {
    enabled = true,
    destinations = { "discord" }
  },
  SECURITY = {
    enabled = true,
    destinations = { "console", "ox_lib" }
  }
}

Send events to both Discord and ox_lib:

Config.Logs = {
  LOG = {
    enabled = true,
    destinations = { "console" }
  },
  EVENT = {
    enabled = true,
    destinations = { "discord", "ox_lib" }
  },
  SECURITY = {
    enabled = true,
    destinations = { "console", "ox_lib" }
  }
}

Disable debug output:

Config.Logs = {
  LOG = {
    enabled = false,
    destinations = { "console" }
  },
  EVENT = {
    enabled = true,
    destinations = { "ox_lib" }
  },
  SECURITY = {
    enabled = true,
    destinations = { "console", "ox_lib" }
  }
}

Visual debug zone markers are separate from logging:

Config.DebugZones = false

Discord Webhook Setup

Discord webhook URLs are configured in config/config.webhooks.lua.

Only add webhook URLs here. Don't put them in config/config.lua, because config.lua is shared with the client.

Webhooks = {}
Webhooks.SelfService = ""
Webhooks.Orders = ""
Webhooks.TabletTuning = ""
Webhooks.Servicing = ""
Webhooks.Invoices = ""
Webhooks.Mechanic = ""
Webhooks.Admin = ""

Webhooks.Shop = ""
Webhooks.Nitrous = ""
Webhooks.Repair = ""
Webhooks.Duty = ""
Webhooks.VehicleData = ""
Webhooks.Security = ""

Discord logs are only sent when the route destination includes "discord".

If a Discord URL is empty, that Discord log is skipped. Other destinations, such as console or ox_lib, will still work.

Migrating Discord Webhooks From server/sv-webhooks.lua

  1. Open your old server/sv-webhooks.lua.
  2. Copy each old webhook URL into the matching entry in config/config.webhooks.lua.
  3. Set your route destinations in config/config.lua.
  4. Add "discord" to any route that should send Discord webhook logs.
  5. Leave new webhook categories blank unless you want logs for those areas.

Old categories are still available:

Old webhookNew config entry
Webhooks.SelfServiceWebhooks.SelfService
Webhooks.OrdersWebhooks.Orders
Webhooks.TabletTuningWebhooks.TabletTuning
Webhooks.ServicingWebhooks.Servicing
Webhooks.InvoicesWebhooks.Invoices
Webhooks.MechanicWebhooks.Mechanic
Webhooks.AdminWebhooks.Admin

New optional categories are:

New webhookUsed for
Webhooks.ShopMechanic shop item purchases
Webhooks.NitrousNitrous bottle installs and refills
Webhooks.RepairSelf-service repair purchases
Webhooks.DutyMechanic duty toggles
Webhooks.VehicleDataVehicle data and statebag warnings
Webhooks.SecurityGeneral security warnings

Discord Appearance

You can also edit the Discord username, avatar, and embed colours in config/config.webhooks.lua:

Config.Logs.Discord = {
  username = "JG Mechanic Webhook",
  avatarUrl = "https://example.com/avatar.png",
  webhooks = Webhooks,
  colors = {
    success = 0x2ecc71,
    danger = 0xe74c3c,
    warning = 0xf1c40f,
    debug = 0x3498db,
    default = 0xff6700
  }
}

On this page