-
Notifications
You must be signed in to change notification settings - Fork 5
Log point
This feature unlike Breakpoint do not stop the script. Instead, they output a message to the Debug console.
What makes them different from traditional log output is that you don't have to modify your script. Also, you can embed variable value. See Embedding value for details.
However, you need to use VSCode's UI to use this feature, so some people may prefer to embed logging process in scripts the traditional way. Debug directive's Output directive is useful in this case.
The log-point can embed the values of AutoHotkey variable and Meta variable. This is enclosed in curly brackets, as in the following example.
count: {A_Index}
{object}
name: {person.name}
{{elapsedTime_s}}
{obj:5}
{obj["key"]}
{obj[var]}
Note that if you output an object, you will not be able to access its children after leaving the function.
To work around this limitation, the following format is provided to retrieve the child elements in advance.
; obj := { a: { b: { c: { d: { e: {} } } } } }
{obj:3}
In the above example, the number represents the depth
of the child element to be retrieved, which in this case is up to c
, but not its children. If depth
is not specified, it is treated as if 1
is specified.
If you specify a large number for depth
, it will take a lot of time to get the data from the debugger (especially for v2). If this happens for 30
seconds, debugging will be forced to stop.
So it is recommended to limit it to about 10
for v1 and 3
~ 5
for v2.
The depth
specification can also be used for some meta variables. Currently, only {variableCategories}
is supported.
{{variableCategories:3}}
{{variableCategories[1]:3}}
If the output contains more than one object, they will be grouped. If the output contains a string in addition to that, the string will be treated as a label as follows
; str := "label"
; obj := { key: "value" }
label{obj} ; => label
{str}{obj} ; => label
{str}{obj}{str} ; => labellabel
{obj} ; => obj
{obj}{obj} ; => obj, obj
If you want to output curly brackets directly, prefix it with \
. e.g. \{A_ThisFunc}
, \{{A_ThisFunc}}