Module logger

Source
Expand description

§Event Logger for TAP Node

This module provides an event logging system that captures all node events and logs them to a configurable location. It implements the EventSubscriber trait to receive events via callbacks from the event bus.

The event logger supports different output formats and destinations, including:

  • Console logging via the standard logging framework
  • File-based logging with rotation support
  • Structured JSON logging for machine readability

§Usage

use std::sync::Arc;
use tap_node::{NodeConfig, TapNode};
use tap_node::event::logger::{EventLogger, EventLoggerConfig, LogDestination};

async fn example() {
    // Create a new TAP node
    let node = TapNode::new(NodeConfig::default());

    // Configure the event logger
    let logger_config = EventLoggerConfig {
        destination: LogDestination::File {
            path: "/var/log/tap-node/events.log".to_string(),
            max_size: Some(10 * 1024 * 1024), // 10 MB
            rotate: true,
        },
        structured: true, // Use JSON format
        log_level: log::Level::Info,
    };

    // Create and subscribe the event logger
    let event_logger = Arc::new(EventLogger::new(logger_config));
    node.event_bus().subscribe(event_logger).await;

    // The event logger will now receive and log all events
}

Structs§

EventLogger
Event logger for TAP Node
EventLoggerConfig
Configuration for the event logger

Enums§

LogDestination
Configuration for where event logs should be sent