{debug:level:store}

Description

Turns AA's internal diagnostic logging on or off for the current page render. It is a developer tool: the command itself produces no visible output (it returns an empty string), it only sets the debug level. When the level is non-zero, AA collects timing and tracing data while it builds the page and prints a diagnostics summary at the end of the render on pages that support it (view.php, the Site module). The level is a bitfield: 0 turns debugging off; bit 1 (value 1) enables page-cache notes; bit 2 (value 2) enables expansion and query tracing; higher bits add more detail (the engine reads levels up to 511). The optional second parameter is a named slot: set it to save the current level before changing it, then later restore that level by calling the command with an empty level and the same slot name. The slot lives only for the current page render. Calling the command with a non-numeric, non-empty level is a special undocumented form whose output is not stable and on this install raises an error - do not rely on it. Because the visible diagnostics depend on which page renders them and on runtime timing, the effect is runtime-dependent; the command's own return value is always empty.

Parameters

level optional default (empty - turns debugging off)

The debug level as an integer bitfield. 0 (or an empty value) turns debugging off. Non-zero turns it on: bit 1 (value 1) adds page-cache notes, bit 2 (value 2) adds expansion and query tracing; higher bits add more detail, up to 511. The command sets this level and returns nothing.

store optional default (empty - no slot used)

Optional name of an internal slot. With a numeric level, the current level is first saved into this slot before being changed; with an empty level, the level saved earlier under this slot name is restored. The slot exists only for the current page render.

Examples

testbefore[{debug:0}]after
Expectedbefore[]after
Actualbefore[]after
Debug is a side-effect command. Wherever you write it, it emits an empty string - here the surrounding text before and after is left untouched. Any visible diagnostics appear later, at the end of the page render.
test[{debug:0}]
Expected[]
Actual[]
Level 0 turns debugging off and returns an empty string. The brackets just make the empty output visible.
test[{debug}]
Expected[]
Actual[]
Calling debug with no level is the same as level 0 - it turns debugging off and returns nothing.
virtual{debug:2}...{debug:0}
Expected(no visible output - turns on expansion and query tracing; the diagnostics summary is printed at the end of the render on pages that support it)
Actual...
Level 2 enables expansion and query tracing for the rest of the page. The command returns nothing in place; on a page that supports it (view.php, the Site module) a timing and trace summary is shown at the end. Marked illustrative because that summary depends on which page renders it.
virtual{debug:3:temp}...some section...{debug::temp}
Expected(no visible output - sets level 3 for the section, then restores the level that was active before)
Actual...some section...
The second parameter names a slot. The first call saves the current level into the slot temp and sets level 3; after the section, the second call with an empty level restores whatever level was saved under temp. Useful to raise detail around one part of a template without leaving debugging on.