| Crates.io | rust-secure-logger |
| lib.rs | rust-secure-logger |
| version | 2.0.0 |
| created_at | 2025-11-18 05:11:33.707313+00 |
| updated_at | 2025-12-11 08:15:18.089252+00 |
| description | Memory-safe security logging for financial systems and critical infrastructure with encryption, log forwarding, and compliance automation |
| homepage | |
| repository | https://github.com/guardsarm/rust-secure-logger |
| max_upload_size | |
| id | 1937910 |
| size | 147,459 |
A memory-safe, thread-safe logging library designed for financial systems and critical infrastructure where security and audit trails are essential.
Built with Rust to eliminate memory safety vulnerabilities that cause 70% of security incidents in traditional C/C++ systems. Aligns with 2024 CISA/FBI guidance recommending memory-safe languages for critical infrastructure.
Add to your Cargo.toml:
[dependencies]
rust-secure-logger = "0.1.0"
use rust_secure_logger::{SecureLogger, SecurityLevel};
fn main() {
let logger = SecureLogger::new();
// Log different security levels
logger.info("Application started");
logger.warning("High memory usage detected");
// Log security events with metadata
logger.security_event(
"Failed login attempt",
Some(serde_json::json!({
"ip": "192.168.1.100",
"username": "admin",
"timestamp": "2024-11-06T00:00:00Z"
}))
);
// Log audit trail for financial transactions
logger.audit(
"Wire transfer initiated",
Some(serde_json::json!({
"amount": 50000.00,
"from_account": "****1234",
"to_account": "****5678",
"user_id": "12345"
}))
);
// Verify integrity of all logs
assert!(logger.verify_all_integrity());
// Export logs as JSON
let json = logger.export_json().unwrap();
println!("{}", json);
}
Every log entry includes a SHA-256 hash of its content for tamper detection:
let entry = LogEntry::new(SecurityLevel::Audit, "Transaction processed".to_string(), None);
assert!(entry.verify_integrity()); // Verify entry hasn't been tampered with
Safe concurrent logging from multiple threads:
use std::thread;
let logger = SecureLogger::new();
let handles: Vec<_> = (0..10).map(|i| {
let logger_clone = logger.clone();
thread::spawn(move || {
logger_clone.info(format!("Thread {} message", i));
})
}).collect();
for handle in handles {
handle.join().unwrap();
}
assert_eq!(logger.get_entries().len(), 10);
// Get all audit entries
let audit_logs = logger.get_entries_by_level(SecurityLevel::Audit);
// Count security events
let security_event_count = logger.count_by_level(SecurityLevel::SecurityEvent);
// Export filtered logs
let critical_logs = logger.get_entries_by_level(SecurityLevel::Critical);
Info - Informational messagesWarning - Warnings that may require attentionSecurityEvent - Security events requiring reviewCritical - Critical security incidentsAudit - Audit trail entries (financial transactions, access control)See the examples/ directory:
cargo run --example basic_usage
cargo run --example audit_trail
cargo test
This library implements security best practices recommended by:
By using Rust, this library eliminates entire classes of vulnerabilities:
Designed for financial institutions requiring:
MIT License - See LICENSE file
Tony Chuks Awunor
Contributions welcome! Please open an issue or pull request.
If you use this library in research or production systems, please cite:
Awunor, T.C. (2024). Rust Secure Logger: Memory-Safe Logging for Financial Systems.
https://github.com/guardsarm/rust-secure-logger
Built for critical infrastructure. Designed for security. Implemented in Rust.