refactor the KafkatorioPacket tag that the mod logs, and the syslog-server parses
This commit is contained in:
parent
ecf680d9ce
commit
dda48bac78
4 changed files with 84 additions and 25 deletions
|
|
@ -1,5 +1,6 @@
|
|||
local ____lualib = require("lualib_bundle")
|
||||
local __TS__Class = ____lualib.__TS__Class
|
||||
local __TS__StringTrim = ____lualib.__TS__StringTrim
|
||||
local __TS__New = ____lualib.__TS__New
|
||||
local ____exports = {}
|
||||
____exports.KafkatorioPacketEmitter = __TS__Class()
|
||||
|
|
@ -15,9 +16,16 @@ function KafkatorioPacketEmitter.prototype.emitKeyedPacket(self, data)
|
|||
end
|
||||
function KafkatorioPacketEmitter.emitPacket(self, packet)
|
||||
local data = game.table_to_json(packet)
|
||||
if #__TS__StringTrim(data) <= 0 then
|
||||
print("[error] table_to_json returned empty string for packet:" .. tostring(packet))
|
||||
return
|
||||
end
|
||||
local encodedData = game.encode_string(data)
|
||||
if encodedData ~= nil then
|
||||
print("KafkatorioPacket encoded::: " .. encodedData)
|
||||
if encodedData == nil or #__TS__StringTrim(encodedData) <= 0 then
|
||||
print("[error] could not encode packet")
|
||||
print("KafkatorioPacket:::" .. data)
|
||||
else
|
||||
print("KafkatorioPacket:::encoded:" .. encodedData)
|
||||
end
|
||||
end
|
||||
local PacketEmitter = __TS__New(____exports.KafkatorioPacketEmitter)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue