Introduction
Depuis : 5.1.23 The $action-log widget is an action widget that can be used to output debugging information to the JavaScript console supported by most browsers. This can be useful to observe and debug the behavior within a sequence of actions.
When the action is invoked, the names and values of all attributes are logged to the JavaScript console.
<$action-log name=value />ActionWidgets are used within triggering widgets such as the ButtonWidget.
- Note
- For debugging outside of actions see LogWidget
Content and Attributes
The $action-log widget is invisible. Any content within it is ignored.
| Attribute | Description |
|---|---|
$$filter | (Optional) All variables whose name matches the Filter Expression will be logged |
$$message | (Optional) A message to display as the title of the information logged. Useful when several $action-log widgets are used in sequence |
$$all | (Optional) Set to yes to log all variables |
- Note
- If
<$action-log />is called without any attributes, all defined variables will be logged as if$$all=yeswere set.
- Note
- When logging Variable Attribute Values, the body text of macros and procedures will be output as their value. Functions are evaluated and their first result is logged.
Examples
Basic Example
Log the value of variable name, the first result of the filter expression [tag[Learning]] and the value of field created of the current tiddler:
<$action-log name=<<name>> filter={{{ [tag[Learning]] }}} created={{!!created}} />Example using $$filter and $$message
Log all core variables (which start with tv-) with a table title:
<$action-log $$message="Core Variables" $$filter="[prefix[tv-]]" />Widget Debugging
Change a misbehaving $action-setfield widget to an $action-log widget to verify that currentTiddler and value match their expected values:
<$action-log $tiddler=<<currentTiddler>> $field="text" $value=<<value>> />This application is the primary reason that the attributes of the $action-log widget are prefixed with two dollar signs instead of one. Otherwise, the attributes of the original widget could be interpreted as attributes to $action-log and lead to unintended consequences.
Example with Function
Log the tiddlerList function definition and its first evaluation result:
\function tiddlerList() [tag[Learning]]
<$action-log $$filter="[title[tiddlerList]]" value=<<tiddlerList>> />- Note
- The values output with the
$$filteror$$allattributes will only contain the definition of functions instead of their values, as the evaluation of many functions can lead to significant performance penalties.