Logging
System observability and log management.
The Logging Module is a module that allows you to log messages to the console.
modules::observability::LoggingModuleSample 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: 5000Configuration
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
modules::observability::adapters::FileLogger
Uses builtin file logger for store logs
class: modules::observability::adapters::FileLogger
config:
file_path: app.log
save_interval_ms: 5000Configuration
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: