lz.DebugService
The Laszlo debugger
JavaScript: lz.DebugService
extends LzBootstrapDebugService (private) »
Debug
is the single instance of the class
lz.DebugService
.
There are three ways to enable the debugger, as described in
the Debugging
chapter of the Developer's Guide.
The debugger can be useful in debugging your own code, but you
should also use debugging to report bugs. The debugger method
LzDebugService.bugReport() will output information
that can be cut and pasted into a bug report to aid in
diagnosing the bug.
The debugger has a range of methods for formatting output to the
debugger console:
LzDebugService.debug(),
LzDebugService.info(),
LzDebugService.warn(), and
LzDebugService.error().
Each of these is based upon the basic formatted output method
LzDebugService.format(). The variants prefix their
message with a label (DEBUG, INFO, WARNING, or ERROR) and will
print in a distinct color. When backtraces are enabled, these
debug messages will also give a source location.
The debug messages can be silenced by setting
Debug.messageLevel.
Debugger messages are inspectable, as the example below
demonstrates. Clicking on the printed representation of the
object (in blue) will show the details of the object. The
message itself can also be inspected. When backtraces are
enabled, one component of the message will be a backtrace that
can be inspected to see the call chain and function arguments
that resulted in the message.
Example 3. Debug output methods
<canvas
debug
="true
" height
="150
">
<debug
y
="5%
" height
="90%
"/>
<script
><![CDATA[
Debug.format("Hello %s!\n", 'world');
Debug.debug("Click there -> %w to inspect the object", {a: 1, b: 2});
]]>
</script
>
</canvas
>
By default, the debugger will intercept runtime errors (instances
of Error that are thrown by the runtime or program) and report
them. These reports can be silenced by throwing values that are
not instances of Error, or by adding
#pragma
"throwsErrors=true"
to the function or method containing the
throw.
The optional <debug> tag controls the appearance of
the debugger console window when debugging is on.
LzBootstrapDebugService (private) »
Methods
-
-
lz.DebugService.bugReport(error : *, verbose : Boolean);
Format information about an error, warning, or other debugger
message suitably for reporting a bug.
This method can be used to create a report suitable for
copy/pasting into a bug report. To use it, enable backtraces and
debugging, inspect the debugger message that you believe reveals a
bug, then invoke `Debug.bugReport()` in the debugger. Copy and
paste the output of that call into your bug report.
-
-
lz.DebugService.debug(args : [*]);
-
-
lz.DebugService.ensureVisible();
Ensure the debugger console is visible. Any debugger output will
implicitly call this, but may be needed if you just want to
ensure the debugger console is visible without creating any
ouput.
-
-
lz.DebugService.error(args : [*]);
-
-
lz.DebugService.explainStyleBindings(node : lz.node, showInherited);
Explain the style bindings of the attributes of a node
For each attribute of the node that has a
style
, the CSS rules that apply to the node
that could affect that binding are displayed. The rules are
displayed (with their source) from the most-specific to the least
specific, and the style names and values of the rule that apply
to this node are displayed. Values that are superceded by more
specific rules are displayed in
italics.
-
-
lz.DebugService.format(control : String, args : [*]);
-
-
lz.DebugService.info(args : [*]);
-
-
lz.DebugService.inspect(obj : Object);
Display the properties of an object on the debug console.
Debug.inspect()
displays each of the
properties of its argument object using
LzDebugService.write().
Long representations (and long Strings)
are abbreviated if they are longer than
Debug.inspectPrintLength,
or deeper than
Debug.inspectPrintDepth.
Properties that are abbreviated are
displayed as links. Clicking on the link will invoke
Debug.inspect()
on that object.
-
-
lz.DebugService.showParent(view);
Display the parent of a view on the debug console.
Debug.showParent()
displays the
parent view of its argument object using
LzDebugService.write().
-
-
lz.DebugService.showSubviews(view);
Display the subviews of a view on the debug console.
Debug.showSubviews()
displays each of the
subviews of its argument object using
LzDebugService.write().
-
-
lz.DebugService.versionInfo();
Display version info.
Displays various version information about the running application
such as the URL it was loaded from, the version of the LPS that is
running and the underlying runtime version.
-
-
lz.DebugService.warn(args : [*]);
-
-
lz.DebugService.write(any : [*]);
Display one or more objects on the debug console.
Note:
LzDebugService.format() allows more control
over displaying multiple objects. Use it instead of
Debug.write.
Debug.write()
displays objects on the debug
console in an informative format. Simple objects are represented
as themselves. Complex objects are represented by their type and
a concise description. Long representations (and long Strings)
are abbreviated if they are longer than
Debug.printLength,
or deeper than
Debug.printDepth.
Complex objects and abbreviated objects are presented as links.
Clicking on the link will invoke
LzDebugService.inspect() on the object,
giving more detail.
LzBootstrapDebugService (private) »
LzBootstrapDebugService (private) »