//! Audit Logging System
//!
//! Provides comprehensive structured audit logging for compliance and security
//! monitoring. Supports multiple storage backends and SIEM integration.
//!
//! # Features
//! - Structured event logging with full context
//! - Multiple storage backends (file, database, SIEM)
//! - Async/non-blocking writes
//! - Automatic log rotation
//! - GDPR compliance (PII hashing, retention policies)
//! - Query interface for Control Center
//! - Export to common SIEM formats (Splunk, ELK)
//!
//! # Example
//! ```ignore
//! use provisioning_orchestrator::audit::{AuditLogger, ActionType, AuditLoggerConfig};
//! use std::path::PathBuf;
//!
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! let config = AuditLoggerConfig {
//!     log_dir: PathBuf::from("/var/log/audit"),
//!     enable_syslog: false,
//!     ..Default::default()
//! };
//! let logger = AuditLogger::new(config).await?;
//!
//! logger.log_action(
//!     "user123",
//!     ActionType::ServerCreate,
//!     "my-infrastructure",
//!     serde_json::json!({"count": 3}),
//! ).await?;
//! # Ok(())
//! # }
//! ```

#[cfg(feature = "nats")]
pub mod collector;
pub mod logger;
pub mod storage;
pub mod types;

use anyhow::Result;
use async_trait::async_trait;
pub use logger::{AuditLogger, AuditLoggerConfig};
pub use storage::{AuditStorage, DatabaseStorage, FileStorage, SiemExporter};
pub use types::{
    ActionInfo, ActionType, AuditEvent, AuditFilter, AuditQuery, AuditResult, AuditStatus,
    AuthorizationInfo, KmsAccess, RetentionPolicy, SiemFormat, UserInfo,
};

/// Audit logging interface
#[async_trait]
pub trait AuditLog: Send + Sync {
    /// Log an audit event
    async fn log(&self, event: AuditEvent) -> Result<()>;

    /// Query audit events
    async fn query(&self, query: AuditQuery) -> Result<Vec<AuditEvent>>;

    /// Export audit events to a specific format
    async fn export(&self, format: SiemFormat, filter: Option<AuditFilter>) -> Result<Vec<u8>>;

    /// Apply retention policy
    async fn apply_retention(&self, policy: RetentionPolicy) -> Result<usize>;
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_module_exports() {
        // Ensure all types are properly exported
        let _: Option<AuditEvent> = None;
        let _: Option<UserInfo> = None;
        let _: Option<ActionInfo> = None;
    }
}
