Skip to content

Commit

Permalink
fix(logger/loki): Fix error when passing invalid/nil tags (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ehbw2 authored Oct 25, 2022
1 parent 5bc6ad9 commit 0d2c06e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion imports/logger/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ if service == 'loki' then
-- Converts a string of comma seperated kvp string to a table of kvps
-- example `discord:blahblah,fivem:blahblah,license:blahblah` -> `{discord="blahblah",fivem="blahblah",license="blahblah"}`
local function convertDDTagsToKVP(tags)
if not tags or type(tags) ~= 'string' then
return {}
end
local tempTable = { string.strsplit(',', tags) } -- outputs a number index table wth k:v strings as values
local bTable = table.create(0, #tempTable) -- buffer table

Expand Down Expand Up @@ -143,7 +146,7 @@ if service == 'loki' then
local values = {message = message}

-- Format the args into strings
local tags = formatTags(source, ... and string.strjoin(',', string.tostringall(...)) or {})
local tags = formatTags(source, ... and string.strjoin(',', string.tostringall(...)) or nil)
local tagsTable = convertDDTagsToKVP(tags)

-- Concatenates tags kvp table to the values table
Expand Down

0 comments on commit 0d2c06e

Please sign in to comment.