Log Node

The Log Node outputs custom messages during test execution for debugging and monitoring purposes. It supports multiple log entries with different severity levels and can save all logs to a context variable for later use.

Use Cases

  • Debugging Test Flows: Print variable values at specific points in the test flow to understand execution state.
  • Progress Tracking: Output messages to track the progress of long-running test sequences.
  • Data Inspection: Log the results of API calls, transformations, or calculations.
  • Audit Trail: Create a log of important events or decision points in your test flow.

Configuration

Log Messages

Each log entry consists of:

  • message: The text to output. Supports both static text and dynamic expressions using:
    • {{variable}} - Direct variable substitution
    • ${expression} - JavaScript expressions (e.g., ${faker.internet.email()})
  • level: The severity level of the log message:
    • INFO - General information (default)
    • WARN - Warning messages
    • ERROR - Error messages
    • DEBUG - Detailed debugging information

Output Variable

  • outputVariable (optional): If specified, all log messages are saved to this context variable as an array of log records, each containing:
    • message: The evaluated message
    • level: The log level
    • timestamp: When the log was generated (in milliseconds)

Examples

Basic Logging

Message: Starting API call to {{apiEndpoint}}
Level: INFO

Dynamic Values with Expressions

Message: Generated email: ${faker.internet.email()}
Level: DEBUG

Message: User count: {{users.length}}, Active: ${users.filter(u => u.active).length}
Level: INFO

Multiple Logs with Output Variable

Configure multiple log entries and save them to executionLogs:

// Log entry 1
Message: Processing {{itemCount}} items
Level: INFO
 
// Log entry 2
Message: Current user: {{userName}}
Level: DEBUG
 
// Log entry 3
Message: Completed at ${new Date().toISOString()}
Level: INFO

After execution, the executionLogs variable will contain:

[
  {
    "message": "Processing 5 items",
    "level": "INFO",
    "timestamp": 1234567890123
  },
  {
    "message": "Current user: john.doe",
    "level": "DEBUG",
    "timestamp": 1234567890124
  },
  {
    "message": "Completed at 2024-10-20T10:23:45.678Z",
    "level": "INFO",
    "timestamp": 1234567890125
  }
]

Available Utilities in Expressions

Within ${expression} blocks, you have access to:

  • faker: Generate fake data (e.g., ${faker.internet.email()}, ${faker.name.firstName()})
  • _ (lodash): Utility functions (e.g., ${_.upperCase('hello')}, ${_.sum([1, 2, 3])})
  • $gen: Value generators (e.g., ${$gen.uuid()}, ${$gen.randomInt(1, 100)})
  • Standard JavaScript: Math, Date, String methods, etc.
  • Context variables: Access any variable directly (e.g., ${userName}, ${response.data.id})

Best Practices

  • Use INFO for general progress: Reserve ERROR and WARN for actual problems or unusual conditions.
  • Keep messages concise: Long log messages can clutter the output; focus on key information.
  • Use DEBUG for detailed inspection: When debugging complex flows, use DEBUG level to avoid overwhelming the main log output.
  • Save important logs to variables: Use the output variable feature when you need to reference logs later in assertions or conditional logic.
  • Use expressions for dynamic content: Leverage template syntax to include runtime values, calculations, and generated data.

Notes

  • Log messages are evaluated at execution time, so they reflect the current state of context variables.
  • Logs are displayed in the test execution details panel with color-coded severity levels.
  • The Log Node does not affect test flow; it’s purely for output and does not validate or modify data.