Module debug
Debug utilities.
Functions
| debug.print(...) | Print a message if global debug is enabled. |
| debug.dump(t[, indent]) | Dump a value as a string. |
| debug.caller(n) | Get the file:line source of the function call at position n in the stack. |
Tables
| debug.enabled | Mapping from category to whether debug is enabled for that category. |
| debug.cats | Table of all categories that have been accessed or set in debug.enabled. |
Fields
| debug.global | Toggle for debug printing. |
Functions
- debug.print(...)
-
Print a message if global debug is enabled.
Parameters:
- ... The args to pass to print.
- debug.dump(t[, indent])
-
Dump a value as a string.
Parameters:
- t The value to dump.
- indent
boolean or string
falseornil: Format entire value on a single line.true: Format table values on multiple lines; indent by four spaces per level- string: Format table values on multiple lines; indent by this string for each level.
- debug.caller(n)
-
Get the file:line source of the function call at position
nin the stack. The value ofnis interpreted equivalently toerror'slevelparameter, i.e. 0 returns a file:line within debug.caller, 1 returns the file:line where debug.caller was invoked, 2 returns the file:line where that function was invoked, etc.Parameters:
- n number The position in the stack trace to get the source location for.
Returns:
-
string
The file and line of the function call at the given position, or the string
"unknown"if no file and line are available.
Tables
- debug.enabled
- Mapping from category to whether debug is enabled for that category. When reading, if a category is not present, the value of debug.global is returned.
- debug.cats
-
Table of all categories that have been accessed or set in debug.enabled.
Accessed categories are mapped to
true.