iii

Logging

System observability and log management.

The Logging Module is a module that allows you to log messages to the console.

modules::observability::LoggingModule

Sample Configuration

- class: modules::observability::LoggingModule
  config:
    level: ${RUST_LOG:info}
    format: json
    adapter:
      class: modules::observability::adapters::FileLogger
      config:
        file_path: app.log
        save_interval_ms: 5000

Configuration

level
string

The level to log. Defaults to info.

adapter
Adapter

The adapter to use. It's the adapter that will be used to store logs.

format
string

The format to log. Defaults to json. When leaving blank, it will use the default format.

Adapters

modules::observability::adapters::RedisLogger

Uses Redis to store logs

class: modules::observability::adapters::RedisLogger
config:
  redis_url: ${REDIS_URL:redis://localhost:6379}

Configuration

redis_url
string

The URL of the Redis instance to use.

modules::observability::adapters::FileLogger

Uses builtin file logger for store logs

class: modules::observability::adapters::FileLogger
config:
  file_path: app.log
  save_interval_ms: 5000

Configuration

file_path
string

path containing the file, where the engine should save

save_interval_ms
string

Interval to store logs. Important, this will only be called if there is additional logs pending to save.

Trigger Type

This Module adds a new Trigger Type: log.

Sample Code

// Register a function to handle log events
bridge.registerFunction({
  function_path: 'monitoring.onError',
  handler: async (logEntry) => {
    console.log('Error logged:', logEntry)
    // Send alert, store in database, etc.
  },
})

// Subscribe to error logs
bridge.registerTrigger({
  trigger_type: 'log',
  function_path: 'monitoring.onError',
  config: {
    level: 'error',
  },
})

Log Entry Structure

When a log trigger fires, the function receives a log entry object:

trace_id
string

Distributed tracing identifier for correlating logs across services.

message
string

The log message content.

level
string

Log severity level (info, warn, error, debug).

function_name
string

The function that generated the log entry.

date
string

ISO 8601 timestamp of when the log was created.

On this page