mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-21 05:06:29 +00:00
* Start splitting apart reconciler, with tests * Reify children in reify * Baseline hydrate implementation * Remove debug print * Scaffold out diff implementation, just supporting name changes * invariant -> error in decodeValue * Flesh out diff and add getProperty * Clear out top-level reconciler interface, start updating code that touches it * Address review feedback * Add (experimental) Selene configuration * Add emptiness checks to PatchSet, remove unimplement invert method * Improve descendant destruction behavior in InstanceMap * Track instanceId on all reify errors * Base implementation of applyPatch, returning partial patches on failure * Change reify to accept InstanceMap and insert instances into it * Start testing applyPatch for removals * Add test for applyPatch adding instances successfully and not * Add , which is just error with formatting * Correctly use new diff and applyPatch APIs * Improve applyPatch logging and fix field name typo * Better debug output when reify fails * Print out unapplied patch in debug mode * Don't write properties if their values are not different. This was exposed trying to sync the Rojo plugin, which has a gigantic ModuleScript in it with the reflection database. This workaround was present in some form in many versions of Rojo, and I guess we still need it. This time, I actually documented why it's here so that I don't forget for the umpteenth time... * Add placeholder test that needs to happen still * Introduce easier plugin testing, write applyPatch properties test * Delete legacy get/setCanonicalProperty files * Fix trying to remove numbers instead of instances * Change applyPatch to return partial patches instead of binary success * Work towards being able to decode and apply refs * Add helpers for PatchSet assertions * Apply refs in reify, test all cases * Improve diagnostics when patches fail to apply * Stop logging when destroying untracked instances, it's ok * Remove read before setting property in applyPatch * Fix diff thinking all properties are changed
60 lines
1.1 KiB
Lua
60 lines
1.1 KiB
Lua
local Fmt = require(script.Parent.Fmt)
|
|
|
|
local Level = {
|
|
Error = 0,
|
|
Warning = 1,
|
|
Info = 2,
|
|
Debug = 3,
|
|
Trace = 4,
|
|
}
|
|
|
|
local function getLogLevel()
|
|
return Level.Info
|
|
end
|
|
|
|
local function addTags(tag, message)
|
|
return tag .. message:gsub("\n", "\n" .. tag)
|
|
end
|
|
|
|
local TRACE_TAG = (" "):rep(15) .. "[Rojo-Trace] "
|
|
local INFO_TAG = (" "):rep(15) .. "[Rojo-Info] "
|
|
local DEBUG_TAG = (" "):rep(15) .. "[Rojo-Debug] "
|
|
local WARN_TAG = "[Rojo-Warn] "
|
|
|
|
local Log = {}
|
|
|
|
Log.Level = Level
|
|
|
|
function Log.setLogLevelThunk(thunk)
|
|
getLogLevel = thunk
|
|
end
|
|
|
|
function Log.trace(template, ...)
|
|
if getLogLevel() >= Level.Trace then
|
|
print(addTags(TRACE_TAG, Fmt.fmt(template, ...)))
|
|
end
|
|
end
|
|
|
|
function Log.info(template, ...)
|
|
if getLogLevel() >= Level.Info then
|
|
print(addTags(INFO_TAG, Fmt.fmt(template, ...)))
|
|
end
|
|
end
|
|
|
|
function Log.debug(template, ...)
|
|
if getLogLevel() >= Level.Debug then
|
|
print(addTags(DEBUG_TAG, Fmt.fmt(template, ...)))
|
|
end
|
|
end
|
|
|
|
function Log.warn(template, ...)
|
|
if getLogLevel() >= Level.Warning then
|
|
warn(addTags(WARN_TAG, Fmt.fmt(template, ...)))
|
|
end
|
|
end
|
|
|
|
function Log.error(template, ...)
|
|
error(Fmt.fmt(template, ...))
|
|
end
|
|
|
|
return Log |