Log input/output data

Log input/output data

CE.png

This page provides an example of what your input and output data might look like in your stream’s Log function after your stream has been run at least once.

Import the example stream below that uses the Log function into your UsageCloud service for more information on the syntax used above. See Streams | Importing an existing stream for more information on importing a stream. This pre-configured stream can be found and executed from the UsageCloud platform for further learning.

Example stream

{ "name": "log (Copy)", "nodes": [ { "id": "5752aa70-2b31-11ec-9f1b-df359e32be28", "name": "Count", "type": "readers/counter", "params": { "max": 10 }, "schemaVersion": 2, "x": 450, "y": 300 }, { "id": "5c7fbd30-2b31-11ec-9f1b-df359e32be28", "name": "Script", "type": "transforms/script", "params": { "transform": "await push({\n ...payload,\n foo: Math.floor(Math.random()*10),\n bar: new Date(),\n baz: {\n a: payload.value,\n b: Math.floor(Math.random()*10),\n c: new Date(),\n }\n});" }, "schemaVersion": 1, "x": 650, "y": 300 }, { "id": "950be7a0-2b31-11ec-9f1b-df359e32be28", "name": "Log one field", "type": "writers/log", "params": { "key": [ "foo" ] }, "schemaVersion": 1, "x": 850, "y": 150 }, { "id": "025a1520-2b32-11ec-9f1b-df359e32be28", "name": "Log multiple fields", "type": "writers/log", "params": { "key": [ "value", "foo", "bar" ] }, "schemaVersion": 1, "x": 850, "y": 300 }, { "id": "19b6c3d0-2b32-11ec-9f1b-df359e32be28", "name": "Log object", "type": "writers/log", "params": { "key": [ "baz" ] }, "schemaVersion": 1, "x": 850, "y": 450 }, { "id": "8c67f640-2b34-11ec-9f1b-df359e32be28", "name": "Log object value by key", "type": "writers/log", "params": { "key": [ "baz.c" ] }, "schemaVersion": 1, "x": 850, "y": 600 } ], "edges": [ { "id": "5e469a80-2b31-11ec-9f1b-df359e32be28", "from": "5752aa70-2b31-11ec-9f1b-df359e32be28", "to": "5c7fbd30-2b31-11ec-9f1b-df359e32be28", "config": {} }, { "id": "96b0be00-2b31-11ec-9f1b-df359e32be28", "from": "5c7fbd30-2b31-11ec-9f1b-df359e32be28", "to": "950be7a0-2b31-11ec-9f1b-df359e32be28", "config": {} }, { "id": "04195150-2b32-11ec-9f1b-df359e32be28", "from": "5c7fbd30-2b31-11ec-9f1b-df359e32be28", "to": "025a1520-2b32-11ec-9f1b-df359e32be28", "config": {} }, { "id": "1b8f5460-2b32-11ec-9f1b-df359e32be28", "from": "5c7fbd30-2b31-11ec-9f1b-df359e32be28", "to": "19b6c3d0-2b32-11ec-9f1b-df359e32be28", "config": {} }, { "id": "8f5aa960-2b34-11ec-9f1b-df359e32be28", "from": "5c7fbd30-2b31-11ec-9f1b-df359e32be28", "to": "8c67f640-2b34-11ec-9f1b-df359e32be28", "config": {} } ], "nodeGroups": [] }

In this example stream, there is a Script function that produces data that are logged by four Log functions. Each Log function is configured with JSON schemas to capture specific keys or objects from the data produced by the Script function.

Example stream.png
The example stream with a Script function that produces data to be logged by four configured Log functions

Input data

The Script functions produces two single field data, and a field with a nested structure that produces three objects.

  • foo: This field produces a random number between one and 10.

  • bar: This field captures the current timestamp when the stream is run.

  • baz: This field contains three nested objects, a, b, c.

    • a: This object duplicates the value field when the stream is run.

    • b: This object produces a random number between one and 10.

    • c: This object captures the current timestamp when the stream is run

The Preview panel in the configuration of the Log function shows a sample of data produced by the Script function that is captured by the Log function.

Input data.png
The sample data produced by the Script function as input for the Log function in the Preview panel
[ { "value": 1, "foo": 3, "bar": "2025-05-23T07:13:11.646Z", "baz": { "a": 1, "b": 0, "c": "2025-05-23T07:13:11.646Z" } }, { "value": 2, "foo": 8, "bar": "2025-05-23T07:13:11.647Z", "baz": { "a": 2, "b": 5, "c": "2025-05-23T07:13:11.647Z" } }, { "value": 3, "foo": 1, "bar": "2025-05-23T07:13:11.647Z", "baz": { "a": 3, "b": 2, "c": "2025-05-23T07:13:11.647Z" } }, { "value": 4, "foo": 8, "bar": "2025-05-23T07:13:11.647Z", "baz": { "a": 4, "b": 0, "c": "2025-05-23T07:13:11.647Z" } }, { "value": 5, "foo": 6, "bar": "2025-05-23T07:13:11.648Z", "baz": { "a": 5, "b": 4, "c": "2025-05-23T07:13:11.648Z" } }, { "value": 6, "foo": 1, "bar": "2025-05-23T07:13:11.648Z", "baz": { "a": 6, "b": 9, "c": "2025-05-23T07:13:11.648Z" } }, { "value": 7, "foo": 4, "bar": "2025-05-23T07:13:11.648Z", "baz": { "a": 7, "b": 6, "c": "2025-05-23T07:13:11.648Z" } }, { "value": 8, "foo": 1, "bar": "2025-05-23T07:13:11.649Z", "baz": { "a": 8, "b": 6, "c": "2025-05-23T07:13:11.649Z" } }, { "value": 9, "foo": 3, "bar": "2025-05-23T07:13:11.649Z", "baz": { "a": 9, "b": 8, "c": "2025-05-23T07:13:11.649Z" } }, { "value": 10, "foo": 0, "bar": "2025-05-23T07:13:11.649Z", "baz": { "a": 10, "b": 6, "c": "2025-05-23T07:13:11.649Z" } } ]

Output data

As a forwarder function type, the Log function does not show any preview of its output data in the stream editor, but the logs messages can be viewed in Logs. Click Logs in the Stream Editor view. Alternatively, go to the stream list, select your stream and click View Log, or select View Log from the Action drop-down list. See Logs for more information.

Below is a sample of the data logged by the Log functions in the stream as seen in the Log view.

Output data.png
The sample data captured by the Logs functions in the Logs view

Note the data captured from the keys and objects by the respective Logs functions according to their configuration.

  • Log one field: Captures data from the foo key.

  • Log multiple field: Captures data from the value, foo, and bar keys.

  • Log object: Captures data from the baz key.

  • Log object value by key: Captures data from the c object in the baz key.