do-memory-mcp 0.1.31

Model Context Protocol (MCP) server for AI agents
Documentation
//! Audit logging operations - Pattern operations
//!
//! This module provides logging methods for pattern-related operations.

use super::core::AuditLogger;
use super::types::AuditLogLevel;
use serde_json::json;

impl AuditLogger {
    /// Log pattern analysis request
    pub async fn log_pattern_analysis(
        &self,
        client_id: &str,
        task_type: &str,
        result_count: usize,
        success: bool,
    ) {
        let metadata = json!({
            "task_type": task_type,
            "result_count": result_count
        });

        self.log_event(
            AuditLogLevel::Debug,
            client_id,
            "analyze_patterns",
            if success { "success" } else { "failure" },
            metadata,
        )
        .await;
    }

    /// Log advanced pattern analysis
    pub async fn log_advanced_pattern_analysis(
        &self,
        client_id: &str,
        analysis_type: &str,
        success: bool,
    ) {
        let metadata = json!({
            "analysis_type": analysis_type
        });

        self.log_event(
            AuditLogLevel::Debug,
            client_id,
            "advanced_pattern_analysis",
            if success { "success" } else { "failure" },
            metadata,
        )
        .await;
    }

    /// Log pattern search
    pub async fn log_pattern_search(
        &self,
        client_id: &str,
        domain: &str,
        result_count: usize,
        success: bool,
    ) {
        let metadata = json!({
            "domain": domain,
            "result_count": result_count
        });

        self.log_event(
            AuditLogLevel::Debug,
            client_id,
            "search_patterns",
            if success { "success" } else { "failure" },
            metadata,
        )
        .await;
    }

    /// Log pattern recommendation request
    pub async fn log_recommend_patterns(
        &self,
        client_id: &str,
        domain: &str,
        recommendation_count: usize,
        success: bool,
    ) {
        let metadata = json!({
            "domain": domain,
            "recommendation_count": recommendation_count
        });

        self.log_event(
            AuditLogLevel::Debug,
            client_id,
            "recommend_patterns",
            if success { "success" } else { "failure" },
            metadata,
        )
        .await;
    }

    /// Log playbook recommendation request (ADR-044 Feature 1)
    pub async fn log_playbook_recommendation(
        &self,
        client_id: &str,
        task_description: &str,
        playbook_count: usize,
        success: bool,
    ) {
        let metadata = json!({
            "task_description": task_description,
            "playbook_count": playbook_count
        });

        self.log_event(
            AuditLogLevel::Info,
            client_id,
            "recommend_playbook",
            if success { "success" } else { "failure" },
            metadata,
        )
        .await;
    }

    /// Log pattern explanation request (ADR-44 Feature 1)
    pub async fn log_pattern_explanation(&self, client_id: &str, pattern_id: &str, success: bool) {
        let metadata = json!({
            "pattern_id": pattern_id
        });

        self.log_event(
            AuditLogLevel::Debug,
            client_id,
            "explain_pattern",
            if success { "success" } else { "failure" },
            metadata,
        )
        .await;
    }
}