log
log
component: log. Formats the message using JavaScript script and records it to a log file.
JavaScript script supports ECMAScript 5.1(+) syntax specification and some ES6 specifications, such as: async/await/Promise/let. It allows calling Go custom functions in the script, please refer to udf .
# Configuration
Field | Type | Description | Default value |
---|---|---|---|
jsScript | string | js script | None |
jsScript
: Formats the message. This field is the following function body contentfunction ToString(msg, metadata, msgType) { ${jsScript} }
1
2
3- msg: Message content, if dataType=JSON, type is:
jsonObject
, you can usemsg.temperature
to operate. If dataType is other types, the field type is:string
- metadata: Message metadata, type:
jsonObject
- msgType: Message type
- Function return value type:
string
- msg: Message content, if dataType=JSON, type is:
TIP
Logger, can be configured by config.Logger , default output to console.
# Relation Type
- Success: Execution successful, send the message to the
Success
chain - Failure: Execution failed, send the message to the
Failure
chain
# Execution result
This component will not change the content of msg.Data
and msg.Metadata
.
# Configuration example
{
"id": "s1",
"type": "log",
"name": "Log",
"configuration": {
"jsScript": "return 'Incoming message:\\n' + JSON.stringify(msg) + '\\nIncoming metadata:\\n' + JSON.stringify(metadata);"
}
}
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
# Application example
Example reference: Example (opens new window)
Edit this page on GitHub (opens new window)
Last Updated: 2024/10/23, 10:13:01