Skip to content

Commit 3ea020c

Browse files
authored
feat(imports/logger): support metadata table for Fivemanage logger (#75)
1 parent db0bd16 commit 3ea020c

File tree

1 file changed

+32
-6
lines changed

1 file changed

+32
-6
lines changed

imports/logger/server.lua

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,17 +128,43 @@ if service == 'fivemanage' then
128128
end)
129129
end
130130

131+
local metadata = {
132+
hostname = hostname,
133+
service = event,
134+
source = source,
135+
}
136+
137+
local playerTags = formatTags(source, nil)
138+
if playerTags and type(playerTags) == 'string' then
139+
local tempTable = { string.strsplit(',', playerTags) }
140+
for _, v in pairs(tempTable) do
141+
local key, value = string.strsplit(':', v)
142+
if key and value then
143+
metadata[key] = value
144+
end
145+
end
146+
end
147+
148+
local args = { ... }
149+
for _, arg in pairs(args) do
150+
if type(arg) == 'table' then
151+
for k, v in pairs(arg) do
152+
metadata[k] = v
153+
end
154+
elseif type(arg) == 'string' then
155+
local key, value = string.strsplit(':', arg)
156+
if key and value then
157+
metadata[key] = value
158+
end
159+
end
160+
end
161+
131162
bufferSize += 1
132163
buffer[bufferSize] = {
133164
level = "info",
134165
message = message,
135166
resource = cache.resource,
136-
metadata = {
137-
hostname = hostname,
138-
service = event,
139-
source = source,
140-
tags = formatTags(source, ... and string.strjoin(',', string.tostringall(...)) or nil),
141-
}
167+
metadata = metadata,
142168
}
143169
end
144170
end

0 commit comments

Comments
 (0)