Ignore global variables
This commit is contained in:
parent
6f7775f602
commit
3e5e46cb74
@ -356,7 +356,7 @@ local PAGES = {
|
||||
end
|
||||
|
||||
|
||||
local storageSatProgress = Progress:new {
|
||||
local storageSatProgress = Progress:new{
|
||||
width = state.width,
|
||||
height = 1
|
||||
-- Percentage of storage slots occupied
|
||||
@ -523,8 +523,6 @@ local PAGES = {
|
||||
table.insert(entries, v)
|
||||
end
|
||||
|
||||
|
||||
|
||||
local mainList = List:new{
|
||||
[Orientation:getId()] = Orientation.VERTICAL,
|
||||
[Children:getId()] = entries
|
||||
|
28
logging.lua
28
logging.lua
@ -25,7 +25,9 @@ function LogLevel.isGreaterOrEqual(a, b)
|
||||
return a >= b
|
||||
end
|
||||
|
||||
local Logger = {}
|
||||
local Logger = {
|
||||
ignoreGlobals = true
|
||||
}
|
||||
Logger.__index = Logger
|
||||
|
||||
function Logger:new(o)
|
||||
@ -46,6 +48,10 @@ function Logger:new(o)
|
||||
return logger
|
||||
end
|
||||
|
||||
function Logger:setIgnoreGlobals(ignoreGlobals)
|
||||
self.ignoreGlobals = ignoreGlobals
|
||||
end
|
||||
|
||||
local RecursionSentinel = {}
|
||||
function RecursionSentinel.make(table)
|
||||
local obj = { table = table }
|
||||
@ -103,10 +109,18 @@ local function cloneNonRecursive(value, sentinels)
|
||||
end
|
||||
end
|
||||
|
||||
local function _simpleStringify(value, builder)
|
||||
local G_ = {}
|
||||
for k,v in pairs(_G) do
|
||||
G_[v] = k
|
||||
end
|
||||
|
||||
local function _simpleStringify(value, builder, ignoreGlobals, skipFunctions)
|
||||
if type(value) == "table" then
|
||||
table.insert(builder, "<")
|
||||
if RecursionSentinel.isSentinel(value) then
|
||||
if ignoreGlobals and G_[value] ~= nil then
|
||||
table.insert(builder, "_G.")
|
||||
table.insert(builder, G_[value])
|
||||
elseif RecursionSentinel.isSentinel(value) then
|
||||
table.insert(builder, "recurse ")
|
||||
table.insert(builder, tostring(value.value))
|
||||
else
|
||||
@ -119,7 +133,7 @@ local function _simpleStringify(value, builder)
|
||||
else
|
||||
first = false
|
||||
end
|
||||
_simpleStringify(v, builder)
|
||||
_simpleStringify(v, builder, ignoreGlobals)
|
||||
end
|
||||
first = #value == 0
|
||||
for k,v in pairs(value) do
|
||||
@ -128,14 +142,14 @@ local function _simpleStringify(value, builder)
|
||||
else
|
||||
first = false
|
||||
end
|
||||
_simpleStringify(k, builder)
|
||||
_simpleStringify(k, builder, ignoreGlobals)
|
||||
table.insert(builder, "=")
|
||||
_simpleStringify(v, builder)
|
||||
_simpleStringify(v, builder, ignoreGlobals)
|
||||
end
|
||||
table.insert(builder, "}")
|
||||
end
|
||||
table.insert(builder, ">")
|
||||
else
|
||||
elseif not skipFunctions or type(value) ~= "function" then
|
||||
local isString = type(value) == "string"
|
||||
if isString then
|
||||
table.insert(builder, "\"")
|
||||
|
Loading…
x
Reference in New Issue
Block a user