Skip to content

(Logger).inspect

Used to look into a given table, it will prevent circular dependency, and use a max depth to prevent "too much". If any given table value has a metatable with a __tostring metafunction, that will be called.

Warning

No two returns may be equal, due to internally using the global pairs function which is known to not always return the same order.

Synopsis

str = Logger.inspector( value, level )

Parameters

value ANY
If a non-table type is given, it will return it using tostring.
level depth or number ("light")
The maximum recursive depth to look into a table if it contains tables. "light" goes a depth of 1, "deep" goes a depth of 3, and number lets you fine tune how much depth.

Returns

str string
A formatted string of the given table, or non-table value, to the specified depth.

Examples

local tbl = {
  foo = "bar",
  tbl = { "foo", "bar" }
}

local str = Logger.inspect(tbl, "light")
print(str)

Logger:info(Logger.inspect(tbl, "deep"))

Logger:info(Logger.inspect(tbl, 3))

local a = { }
local b = { }
a["b"] = b
b["a"] = a

Logger:warning(Logger.inspect(a, "deep"))

See Also