Print Log

In this section, we will learn how to use the Print Log block.

Use Cases

During software development, logging is a crucial aspect as it provides valuable insights into the state of the program, helps identify issues, and optimize performance.

Similarly, when building workflows in Tapicker, logging allows you to verify if a workflow is executed correctly. That's the purpose of this block.

example

This will output the following log:

[2024-10-13 13:27:12.402] INFO PrintLog(1f331b84) "Hello World!"

For simplicity, the following examples show only the printed value. Strings appear in double quotes; numbers, booleans, null, and undefined appear without quotes.

Printing Variable Values

Suppose $vars.name = "Anna". You can print its value as follows:

Name: {{$vars.name}}

This will output the following log:

"Name: Anna"

A single expression preserves the value's type. For example, if $vars.count = 3 and $vars.enabled = false:

{{$vars.count}}   // 3
{{$vars.enabled}} // false
{{undefined}}    // undefined

Adding text around an expression produces a string, as in Name: {{$vars.name}} above.

Printing Arrays

Example 1: When $vars.array = [ 1, 2, 3 ]

{{$vars.array}} // [1,2,3]

Example 2: When $vars.array = [ {"name": 1}, {"name": 2}, {"name": 3} ]

{{$vars.array}} // [{"name":1},{"name":2},{"name":3}]

An expression such as {{$vars.array}} prints the array as a value. You do not need to use toString(). Long arrays and strings may appear shortened in the Logs panel; Copy Logs gives you the complete saved content.

Use toString() when you specifically want to convert the values to strings:

{{$vars.array|toString()}} // ["{\"name\":1}","{\"name\":2}","{\"name\":3}"]

For an array, toString() converts each item independently and keeps the array shape.

Printing JSON

Example 1: When $vars.json = { "name": 123 }

{{$vars.json}} // {"name":123}

An expression such as {{$vars.json}} prints the object as a value. If you use toString(), the result is a string, with its quotes escaped in the log:

{{$vars.json|toString()}} // "{\"name\":123}"