Fivemerr
  • Fivemerr
    • πŸ€“Welcome to Fivemerr
  • API
    • βœ…Setup
    • πŸ–ΌοΈImages
    • πŸ”ŠAudio
    • πŸŽ₯Video
    • ℹ️Logs
  • Features
    • πŸ”„DB Backups
    • πŸ”‰Media
    • πŸ“­API Tokens
    • πŸ’»Servers
    • πŸͺ’Logs
    • πŸ•ΈοΈWebhooks
  • Script Integrations
    • πŸ“Έscreenshot-basic
    • 🀳ShareX
    • ℹ️Logs
      • ℹ️fm-logs
      • ℹ️ox_logs
      • ℹ️qb-logs
    • πŸ“ΆPhone Scripts
      • πŸ“³QBCore Phone
      • πŸ“³LB Phone
      • πŸ“³Road Phone
      • πŸ“³NPWD
      • πŸ“³JP Phone
      • πŸ“³nPhone
      • πŸ“΄okokPhone
      • πŸ“³GKS Phone
      • πŸ“³YSeries Phone
      • πŸ“΅QS Phone
    • πŸ¦₯Project Sloth
      • πŸ¦₯ps-mdt
      • πŸ¦₯ps-adminmenu
      • πŸ¦₯ps-camera
    • πŸ’ͺPower Scripts
      • πŸ’ͺpower_dashcams
    • πŸ“ΉSpy Scripts
      • πŸ“Ήspy-bodycam
Powered by GitBook
On this page
  1. Script Integrations
  2. Logs

ox_logs

Previousfm-logsNextqb-logs

Last updated 9 months ago

Download the snippet here

Thanks to trapson for the snippet.

Add the below snippet on:

ox_lib\imports\logger\server.lua
if service == 'fivemerr' then
    local key = GetConvar('fivemerr:key', '')

    if key ~= '' then
        local endpoint = 'https://api.fivemerr.com/v1/logs'

        local headers = {
            ['Authorization'] = key,
            ['Content-Type'] = 'application/json',
            ['User-Agent'] = 'ox_lib'
        }

        function lib.logger(source, event, message, ...)
            if not buffer then
                buffer = {}

                SetTimeout(500, function()
                    PerformHttpRequest(endpoint, function(status, _, _, response)
                        if status ~= 200 then 
                            if type(response) == 'string' then
                                response = json.decode(response) or response
                                badResponse(endpoint, status, response)
                            end
                        end
                    end, 'POST', json.encode(buffer), headers)

                    buffer = nil
                end)
            end

            buffer = {
                level = "info",
                message = event .. " - " .. message,
                resource = cache.resource,
                metadata = {
                    event = event,
                    playerid = source,
                    tags = formatTags(source, ... and string.strjoin(',', string.tostringall(...)) or nil),
                }
            }
        end
    end
end

Add this to your server.cfg with your Logs API KEY.

set ox:logger "fivemerr"
# Get the key from API Tokens on Fivemerr Panel
set fivemerr:key "API KEY HERE"
# Logging via ox_lib (0: Disable, 1: Standard, 2: Include AddItem/RemoveItem, and all shop purchases)
set inventory:loglevel 2

Preview:

ℹ️
ℹ️
Fivemerr's OX LIB