inspect_api.lua 894 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. local inspect_lib = require "inspect"
  2. function inspect(value)
  3. return inspect_lib(value, {
  4. process = function(item, path)
  5. if type(item) == "function" then
  6. return nil
  7. end
  8. if path[#path] == inspect_lib.METATABLE then
  9. return nil
  10. end
  11. return item
  12. end,
  13. newline = " ",
  14. indent = ""
  15. })
  16. end
  17. function DUMP(value)
  18. return inspect_lib(value, {
  19. process = function(item, path)
  20. return item
  21. end,
  22. newline = " ",
  23. indent = ""
  24. })
  25. end
  26. function TraceBack()
  27. for level = 1, math.huge do
  28. local info = debug.getinfo(level, "nSl")
  29. if not info then break end
  30. if info.what == "C" then -- is a C function?
  31. DEBUG(level, "C function")
  32. else
  33. DEBUG(info.name,string.format("%d, [%s] : %d", level, info.short_src, info.currentline))
  34. end
  35. end
  36. end