diff --git a/plugin/src/Components/App.lua b/plugin/src/Components/App.lua index 246b60cd..824f6d10 100644 --- a/plugin/src/Components/App.lua +++ b/plugin/src/Components/App.lua @@ -133,7 +133,7 @@ function App:startSession(address, port) -- Details being present indicates that this -- disconnection was from an error. if details ~= nil then - Log.warn(tostring(details)) + Log.warn("Disconnected from an error: {}", details) self:setState({ appStatus = AppStatus.Error, @@ -207,7 +207,7 @@ function App:render() end function App:didMount() - Log.trace("Rojo %s initializing", self.displayedVersion) + Log.trace("Rojo {} initializing", self.displayedVersion) checkUpgrade(self.props.plugin) preloadAssets() diff --git a/plugin/src/InstanceMap.lua b/plugin/src/InstanceMap.lua index 43476fb3..4c497c0a 100644 --- a/plugin/src/InstanceMap.lua +++ b/plugin/src/InstanceMap.lua @@ -20,14 +20,16 @@ function InstanceMap.new(onInstanceChanged) return setmetatable(self, InstanceMap) end -function InstanceMap:debugState() - local buffer = {} +function InstanceMap:__fmtDebug(output) + output:writeLine("InstanceMap {{") + output:indent() for id, instance in pairs(self.fromIds) do - table.insert(buffer, string.format("- %s: %s", id, instance:GetFullName())) + output:writeLine("- {}: {}", id, instance:GetFullName()) end - return table.concat(buffer, "\n") + output:unindent() + output:writeLine("}") end function InstanceMap:insert(id, instance) @@ -44,7 +46,7 @@ function InstanceMap:removeId(id) self.fromIds[id] = nil self.fromInstances[instance] = nil else - Log.warn("Attempted to remove nonexistant ID %s", tostring(id)) + Log.warn("Attempted to remove nonexistant ID {}", id) end end @@ -56,7 +58,7 @@ function InstanceMap:removeInstance(instance) self.fromInstances[instance] = nil self.fromIds[id] = nil else - Log.warn("Attempted to remove nonexistant instance %s", tostring(instance)) + Log.warn("Attempted to remove nonexistant instance {}", instance) end end @@ -66,7 +68,7 @@ function InstanceMap:destroyInstance(instance) if id ~= nil then self:destroyId(id) else - Log.warn("Attempted to destroy untracked instance %s", tostring(instance)) + Log.warn("Attempted to destroy untracked instance {}", instance) end end @@ -89,7 +91,7 @@ function InstanceMap:destroyId(id) instance:Destroy() else - Log.warn("Attempted to destroy nonexistant ID %s", tostring(id)) + Log.warn("Attempted to destroy nonexistant ID {}", id) end end diff --git a/plugin/src/Reconciler.lua b/plugin/src/Reconciler.lua index 7ab35cb6..7bffa2b4 100644 --- a/plugin/src/Reconciler.lua +++ b/plugin/src/Reconciler.lua @@ -134,10 +134,10 @@ function Reconciler:applyPatch(patch) if parentInstance == nil then invariant( - "Cannot add an instance from a patch that has no parent.\nInstance %s with parent %s.\nInstanceMap state:\n%s", + "Cannot add an instance from a patch that has no parent.\nInstance {} with parent {}.\nState: {:#?}", id, - tostring(apiInstance.Parent), - self.__instanceMap:debugState() + apiInstance.Parent, + self.__instanceMap ) end @@ -150,9 +150,9 @@ function Reconciler:applyPatch(patch) if instance == nil then invariant( - "Cannot update an instance that does not exist in the reconciler's state.\nInstance ID %s\nInstanceMap state:\n%s", + "Cannot update an instance that does not exist in the reconciler's state.\nInstance {}\nState: {:#?}", update.id, - self.__instanceMap:debugState() + self.__instanceMap ) end diff --git a/plugin/src/invariant.lua b/plugin/src/invariant.lua index 3923095b..7cb813b4 100644 --- a/plugin/src/invariant.lua +++ b/plugin/src/invariant.lua @@ -1,16 +1,18 @@ +local Fmt = require(script.Parent.Parent.Fmt) + local Config = require(script.Parent.Config) local invariant if Config.isDevBuild then function invariant(message, ...) - message = string.format(message, ...) + message = Fmt.fmt(message, ...) error("Invariant violation: " .. message, 2) end else function invariant(message, ...) - message = string.format(message, ...) + message = Fmt.fmt(message, ...) local fullMessage = string.format( "Rojo detected an invariant violation within itself:\n" .. diff --git a/plugin/src/preloadAssets.lua b/plugin/src/preloadAssets.lua index a8a4a4f1..c23d2dd1 100644 --- a/plugin/src/preloadAssets.lua +++ b/plugin/src/preloadAssets.lua @@ -19,7 +19,7 @@ local function preloadAssets() table.insert(contentUrls, url) end - Log.trace("Preloading assets: %s", table.concat(contentUrls, ", ")) + Log.trace("Preloading assets: {:?}", contentUrls) coroutine.wrap(function() ContentProvider:PreloadAsync(contentUrls)