RuleGo RuleGo
🏠Home
  • Quick Start
  • Rule Chain
  • Standard Components
  • Extension Components
  • Custom Components
  • Visualization
  • RuleGo-Server
  • RuleGo-MCP-Server
  • AOP
  • Trigger
  • Advanced Topics
  • Performance
  • Standard Components
  • Extension Components
  • Custom Components
  • Components Marketplace
  • Overview
  • Quick Start
  • Routing
  • DSL
  • API
  • Options
  • Components
🔥Editor (opens new window)
  • RuleGo Editor (opens new window)
  • RuleGo Server (opens new window)
  • Github (opens new window)
  • Gitee (opens new window)
  • Changelog (opens new window)
  • English
  • 简体中文
🏠Home
  • Quick Start
  • Rule Chain
  • Standard Components
  • Extension Components
  • Custom Components
  • Visualization
  • RuleGo-Server
  • RuleGo-MCP-Server
  • AOP
  • Trigger
  • Advanced Topics
  • Performance
  • Standard Components
  • Extension Components
  • Custom Components
  • Components Marketplace
  • Overview
  • Quick Start
  • Routing
  • DSL
  • API
  • Options
  • Components
🔥Editor (opens new window)
  • RuleGo Editor (opens new window)
  • RuleGo Server (opens new window)
  • Github (opens new window)
  • Gitee (opens new window)
  • Changelog (opens new window)
  • English
  • 简体中文

广告采用随机轮播方式显示 ❤️成为赞助商
  • Quick Start

  • Rule Chain

  • Standard Components

    • Standard Components Overview
    • filter

    • action

      • log
        • Configuration
        • Relation Type
        • Execution result
        • Configuration example
        • Application example
      • functions
      • delay
      • groupAction
      • iterator
      • for
      • exec
      • join
    • transform

    • external

    • flow

  • Extension Components

  • Custom Components

  • Components marketplace

  • Visualization

  • AOP

  • Trigger

  • Advanced Topic

  • RuleGo-Server

  • FAQ

  • Endpoint Module

  • Support

目录

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 content

        function ToString(msg, metadata, msgType) { 
            ${jsScript} 
         }
    
    1
    2
    3
    • msg: Message content, if dataType=JSON, type is: jsonObject, you can use msg.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

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

# Application example

Example reference: Example (opens new window)

Edit this page on GitHub (opens new window)
Last Updated: 2025/04/02, 01:29:50
Switch
functions

← Switch functions→

Theme by Vdoing | Copyright © 2023-2025 RuleGo Team | Apache 2.0 License

  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式