From 0d2c06e982edca9e4bd48ee20845501fe48eb62b Mon Sep 17 00:00:00 2001 From: Ehbw2 Date: Tue, 25 Oct 2022 16:30:53 +0100 Subject: [PATCH] fix(logger/loki): Fix error when passing invalid/nil tags (#139) --- imports/logger/server.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/imports/logger/server.lua b/imports/logger/server.lua index 936c2cc..7f4973d 100644 --- a/imports/logger/server.lua +++ b/imports/logger/server.lua @@ -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 @@ -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