mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 15:06:02 +01:00
Mostly a change for improved intellisense with sumneko lua. Includes some type fixes and deprecation notices.
31 lines
901 B
Lua
31 lines
901 B
Lua
local key = GetConvar('datadog:key', '')
|
|
|
|
if key ~= '' then
|
|
local site = ('https://http-intake.logs.%s/api/v2/logs'):format(GetConvar('datadog:site', 'datadoghq.com'))
|
|
local resourceName = GetCurrentResourceName()
|
|
key = key:gsub("[\'\"]", '')
|
|
|
|
function lib.logger(source, event, message, ...)
|
|
local data = json.encode({
|
|
hostname = resourceName,
|
|
service = event,
|
|
message = message,
|
|
ddsource = tostring(source),
|
|
ddtags = string.strjoin(',', string.tostringall(...))
|
|
})
|
|
|
|
PerformHttpRequest(site, function(status, _, _, response)
|
|
if status ~= 202 then
|
|
-- Thanks, I hate it
|
|
response = json.decode(response:sub(10)).errors[1]
|
|
print(('unable to submit logs to %s\n%s'):format(site, json.encode(response, {indent=true})))
|
|
end
|
|
end, 'POST', data, {
|
|
['Content-Type'] = 'application/json',
|
|
['DD-API-KEY'] = key
|
|
})
|
|
end
|
|
end
|
|
|
|
return lib.logger or function() end
|