-- Compiled with roblox-ts v1.2.7 local TS = _G[script] local LogLevel = TS.import(script, TS.getModule(script, "@rbxts", "log").out).LogLevel local MessageTemplateParser = TS.import(script, TS.getModule(script, "@rbxts", "message-templates").out).MessageTemplateParser local _MessageTemplateToken = TS.import(script, TS.getModule(script, "@rbxts", "message-templates").out.MessageTemplateToken) local DestructureMode = _MessageTemplateToken.DestructureMode local TemplateTokenKind = _MessageTemplateToken.TemplateTokenKind local RbxSerializer = TS.import(script, TS.getModule(script, "@rbxts", "message-templates").out.RbxSerializer).RbxSerializer local RunService = game:GetService("RunService") local ZirconContext do ZirconContext = setmetatable({}, { __tostring = function() return "ZirconContext" end, }) ZirconContext.__index = ZirconContext function ZirconContext.new(...) local self = setmetatable({}, ZirconContext) return self:constructor(...) or self end function ZirconContext:constructor(innerContext, executingFunction) self.innerContext = innerContext self.executingFunction = executingFunction self.logs = {} end function ZirconContext:GetExecutor() local executor = self.innerContext:getExecutor() assert(executor) return executor end function ZirconContext:Log(level, template, ...) local args = { ... } if RunService:IsServer() then local _promise = TS.Promise.new(function(resolve) resolve(TS.import(script, script.Parent.Parent, "Services", "LogService")) end) local _arg0 = function(log) local message = { Level = level, SourceContext = "(function '" .. (self.executingFunction:GetName() .. "')"), Template = template, Timestamp = DateTime.now():ToIsoDate(), LogToPlayer = self:GetExecutor(), } local tokens = MessageTemplateParser.GetTokens(template) local _arg0_1 = function(t) return t.kind == TemplateTokenKind.Property end -- ▼ ReadonlyArray.filter ▼ local _newValue = {} local _length = 0 for _k, _v in ipairs(tokens) do if _arg0_1(_v, _k - 1, tokens) == true then _length += 1 _newValue[_length] = _v end end -- ▲ ReadonlyArray.filter ▲ local propertyTokens = _newValue local idx = 0 for _, token in ipairs(propertyTokens) do local _exp = args local _original = idx idx += 1 local arg = _exp[_original + 1] if idx <= #args then if arg ~= nil then if token.destructureMode == DestructureMode.ToString then message[token.propertyName] = tostring(arg) else message[token.propertyName] = type(arg) == "table" and arg or RbxSerializer.Serialize(arg) end end end end log.ZirconLogService.WriteStructured(message) local _logs = self.logs -- ▼ Array.push ▼ _logs[#_logs + 1] = message -- ▲ Array.push ▲ end _promise:andThen(_arg0) else local _promise = TS.Promise.new(function(resolve) resolve(TS.import(script, script.Parent.Parent, "Client")) end) local _arg0 = function(_param) local client = _param.default local log = { Level = level, SourceContext = "(function '" .. (self.executingFunction:GetName() .. "')"), Template = template, Timestamp = DateTime.now():ToIsoDate(), LogToPlayer = self:GetExecutor(), } client.StructuredLog(log) local _logs = self.logs -- ▼ Array.push ▼ _logs[#_logs + 1] = log -- ▲ Array.push ▲ end _promise:andThen(_arg0) end end function ZirconContext:LogInfo(template, ...) local args = { ... } self:Log(LogLevel.Information, template, unpack(args)) end function ZirconContext:LogWarning(template, ...) local args = { ... } self:Log(LogLevel.Warning, template, unpack(args)) end function ZirconContext:LogError(template, ...) local args = { ... } self:Log(LogLevel.Error, template, unpack(args)) end function ZirconContext:GetLogs() return self.logs end function ZirconContext:GetOutput() return self.innerContext:getOutput() end function ZirconContext:GetInput() return self.innerContext:getInput() end function ZirconContext:GetFunctionName() return self.executingFunction:GetName() end end return { ZirconContext = ZirconContext, }