๐ฏ A high-performance, secure, and feature-rich logging infrastructure built on Tokio
Inklog provides a comprehensive logging solution for enterprise applications:
| โก High Performance | ๐ Security First | ๐ Multi-Target | ๐ Observability |
|---|---|---|---|
| Async I/O with Tokio | AES-256-GCM encryption | Console, File, DB | Health monitoring |
| Batch writes & compression | Zeroized secret memory | Automatic rotation | Metrics & tracing |
use ;
use PathBuf;
async
๐ Table of Contents
- โจ Features
- ๐ Quick Start
- ๐จ Feature Flags
- ๐ Documentation
- ๐ป Examples
- ๐๏ธ Architecture
- ๐ Security
- ๐งช Testing
- ๐ค Contributing
- ๐ ๆดๆฐๆฅๅฟ
- ๐ License
- ๐ Acknowledgments
โจ Features
| ๐ฏ Core Features | โก Enterprise Features |
|---|---|
| Always Available | Optional |
๐ฏ Core Features (Always Available)
| Status | Feature | Description |
|---|---|---|
| โ | Async I/O | Tokio-powered non-blocking logging |
| โ | Multi-Target Output | Console, file, database, custom sinks |
| โ | Structured Logging | tracing ecosystem integration |
| โ | Custom Formatting | Template-based log format |
| โ | File Rotation | Size-based and time-based rotation |
| โ | Data Masking | Regex-based PII redaction |
| โ | Health Monitoring | Sink status and metrics tracking |
| โ | CLI Tools | decrypt, generate, validate commands |
โก Enterprise Features
| Status | Feature | Description |
|---|---|---|
| ๐ | Compression | ZSTD, GZIP, Brotli, LZ4 support (zstd, flate2, etc.) |
| ๐ | Encryption | AES-256-GCM file encryption (aes-gcm) |
| ๐๏ธ | Database Sink | PostgreSQL, MySQL, SQLite via Sea-ORM |
| ๐ | Parquet Export | Analytics-ready log format (always available) |
| ๐ | HTTP Endpoint | Axum-based health check server (http feature) |
| ๐ง | CLI Tools | Utility commands for log management (cli feature) |
๐ฆ Feature Presets
| Preset | Features | Use Case |
|---|---|---|
| minimal | No optional features | Core logging only |
| standard | http, cli |
Standard development setup |
| full | All default features | Production-ready logging |
๐ Quick Start
๐ฆ Installation
Add this to your Cargo.toml:
[]
= "0.1"
For full feature set:
[]
= { = "0.1", = ["default"] }
๐ก Basic Usage
๐ฌ 5-Minute Quick Start
Step 1: Initialize Logger
use LoggerManager;
async
Step 2: Log Messages
use LoggerManager;
async
Step 3: File Logging
use ;
let config = InklogConfig ;
let _logger = with_config.await?;
Step 4: Database Logging
use ;
let config = InklogConfig ;
let _logger = with_config.await?;
๐ง Advanced Configuration
Encrypted File Logging
use ;
// Set encryption key from environment
set_var;
let config = InklogConfig ;
let _logger = with_config.await?;
Custom Log Format
use ;
let format_string = "[{timestamp}] [{level:>5}] {target} - {message} | {file}:{line}";
let config = InklogConfig ;
let _logger = with_config.await?;
๐จ Feature Flags
Default Features
= "0.1" # Includes: http, cli
Optional Features
# HTTP Server
= { = "0.1", = [
"http", # Axum HTTP health endpoint
] }
# CLI Tools
= { = "0.1", = [
"cli", # decrypt, generate, validate commands
] }
# Database Sinks (pick one or more)
= { = "0.1", = [
"sqlite", # SQLite database sink
"postgres", # PostgreSQL database sink
"mysql", # MySQL database sink
] }
# Development
= { = "0.1", = [
"test-local", # Local testing mode
"debug", # Additional security audit logging
] }
Feature Details
| Feature | Dependencies | Description |
|---|---|---|
| http | axum | HTTP health check endpoint |
| cli | clap, glob | Command-line utilities |
| sqlite | dbnexus, sea-orm | SQLite database sink |
| postgres | dbnexus, sea-orm | PostgreSQL database sink |
| mysql | dbnexus, sea-orm | MySQL database sink |
| duckdb | dbnexus, sea-orm | DuckDB backend (only for --all-features testing; DatabaseSink does not directly support duckdb driver) |
| test-local | - | Local testing mode |
| debug | - | Security audit logging |
| metrics | - | Health metrics collection |
| kit | trait-kit, dbnexus, oxcache | Dependency injection kit integration |
๐ Documentation
๐ Additional Resources
| Resource | Description |
|---|---|
| ๐ API Reference | Complete API documentation on docs.rs |
| ๐๏ธ Architecture | System architecture and design decisions |
| ๐ Security | Security best practices and features |
| ๐ฆ Examples | Working code examples for all features |
๐ป Examples
๐ก Real-world Examples
๐ Basic Logging
use LoggerManager;
async
๐ File Logging with Rotation
use ;
let config = InklogConfig ;
let _logger = with_config.await?;
๐ Encrypted Logging
use ;
set_var;
let config = InklogConfig ;
let _logger = with_config.await?;
๐๏ธ Database Logging
use ;
let config = InklogConfig ;
let _logger = with_config.await?;
๐ฅ HTTP Health Endpoint
use ;
use LoggerManager;
use Arc;
let logger = new;
let app = new.route;
// Start HTTP server...
๐จ Custom Format
use ;
let format_string = "[{timestamp}] [{level:>5}] {target} - {message}";
let config = InklogConfig ;
let _logger = with_config.await?;
๐ Data Masking
use ;
let config = InklogConfig ;
let _logger = with_config.await?;
// Sensitive data will be automatically masked
info!;
// Output: User email: ***@***.***
๐ฆ Runnable Examples
The examples/ crate provides 10 dedicated examples demonstrating specific features. Run them with cargo run --example <name> (from the examples/ directory or with --package inklog-examples).
| Example | Description | Run Command |
|---|---|---|
object_pool |
Object pool reuse for allocation-heavy paths | cargo run --example object_pool |
path_validator |
Path validation for safe file sink targets | cargo run --example path_validator |
log_sanitizer |
Log input sanitization to prevent log injection | cargo run --example log_sanitizer |
log_adapter |
Bridging log and tracing ecosystems |
cargo run --example log_adapter |
compression |
File sink compression (ZSTD/GZIP/Brotli/LZ4) | cargo run --example compression |
rotation |
Size-based and time-based file rotation | cargo run --example rotation |
ring_buffered_file |
Ring-buffered file sink for high throughput | cargo run --example ring_buffered_file |
config_file |
TOML configuration file loading | cargo run --example config_file |
metrics |
Health metrics and Prometheus export | cargo run --example metrics |
circuit_breaker |
Sink circuit breaker and failure recovery | cargo run --example circuit_breaker |
Note:
inklog-examplesis now part of the workspace.
๐๏ธ Architecture
๐๏ธ System Architecture
flowchart TD
App["Application Layer<br/>(Your code using log! macros)"]
API["Inklog API Layer<br/>- LoggerManager, LoggerBuilder<br/>- Configuration management<br/>- Health monitoring"]
Sink["Sink Abstraction Layer<br/>- ConsoleSink<br/>- FileSink (rotation, compression)<br/>- DatabaseSink (batch writes)<br/>- AsyncFileSink<br/>- RingBufferedFileSink"]
Core["Core Processing Layer<br/>- Log formatting & templates<br/>- Data masking (PII redaction)<br/>- Encryption (AES-256-GCM)<br/>- Compression (ZSTD, GZIP, Brotli)"]
IO["Concurrency & I/O<br/>- Tokio async runtime<br/>- Crossbeam channels<br/>- Rayon parallel processing"]
Store["Storage & External Services<br/>- Filesystem<br/>- Database (PostgreSQL, MySQL, SQLite)<br/>- Parquet (analytics)"]
App --> API --> Sink --> Core --> IO --> Store
Layer-by-Layer Explanation
Application Layer
- Application code uses standard
log!macros from thelogcrate - Compatible with existing Rust logging patterns
Inklog API Layer
LoggerManager: Main orchestrator for all logging operationsLoggerBuilder: Fluent builder pattern for configuration- Health status tracking and metrics collection
Sink Abstraction Layer
- Multiple sink implementations for different output targets
- Console output for development
- File output with rotation, compression, and encryption
- Database output with batch writes (PostgreSQL, MySQL, SQLite)
- Async and buffered file sinks for high-throughput scenarios
Core Processing Layer
- Template-based log formatting
- Regex-based PII data masking (emails, SSNs, credit cards)
- AES-256-GCM encryption for sensitive logs
- Multiple compression algorithms (ZSTD, GZIP, Brotli, LZ4)
Concurrency & I/O Layer
- Tokio async runtime for non-blocking I/O
- Crossbeam channels for inter-task communication
- Rayon for CPU-intensive parallel processing
Storage & External Services Layer
- Local filesystem access
- Database connectivity via Sea-ORM
- Parquet format for analytics workflows
๐ Security
๐ก๏ธ Security Features
Inklog is built with security as a top priority:
๐ Encryption
- AES-256-GCM: Military-grade encryption for log files
- Key Management: Environment variable-based key injection
- Zeroized Memory: Secrets are securely cleared after use via
zeroizecrate - SHA-256 Hashing: Integrity verification for encrypted logs
๐ญ Data Masking
- Regex-Based Patterns: Automatic PII detection and redaction
- Email Masking:
user@example.comโ***@***.*** - SSN Masking: Credit card and social security number redaction
- Custom Patterns: Configurable regex patterns for sensitive data
๐ Secure Key Handling
// Set encryption key securely from environment
set_var;
// Key is automatically zeroized after use
// Never hardcode keys in your application
๐ก๏ธ Security Best Practices
- No hardcoded secrets: Keys loaded from environment variables
- Minimal privileged operations: Only necessary file/database access
- Audit logging: Debug feature for security audit trails
- Compliance-ready: Supports GDPR, HIPAA, PCI-DSS logging requirements
๐งช Testing
๐ฏ Run Tests
# Run all tests with default features
# Run tests with specific features
# Run tests in release mode
# Run benchmarks
Test Coverage
Inklog targets 95%+ code coverage:
# Generate coverage report
Linting and Formatting
# Format code
# Check formatting without changes
# Run Clippy (warnings as errors)
Security Audit
# Run cargo deny for security checks
# Check for advisories
# Check for banned licenses
Dependency Injection Testing
Inklog provides Mock implementations for unit testing without external dependencies:
use ;
use ;
use Arc;
async
Mock Implementations:
- MockCache: In-memory HashMap with delay simulation
- MockConfig: Runtime-modifiable configuration
- MockDatabaseAdapter: In-memory log storage with health state control
See User Guide for detailed usage.
Integration Tests
# Run integration tests
# Run with Docker services (PostgreSQL, MySQL)
๐ค Contributing
Contributions are welcome! ่ฏฆ่ง CONTRIBUTING.md
Development Setup
# Clone repository
# Install pre-commit hooks (if available)
# Run tests
# Run linter
# Format code
Pull Request Process
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests and ensure all pass (
cargo test --all-features) - Run clippy and fix warnings (
cargo clippy --all-features) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Code Style
- Follow Rust naming conventions (snake_case for variables, PascalCase for types)
- Use
thiserrorfor error types - Use
anyhowfor error contexts - Add doc comments to all public APIs
- Run
cargo fmtbefore committing
๐ ๆดๆฐๆฅๅฟ
่ฏฆ่ง CHANGELOG.md
๐ License
This project is licensed under the MIT License.
MIT License, Copyright (c) 2026 Kirky.X
๐ Acknowledgments
๐ Built on Excellent Tools
Inklog wouldn't be possible without these amazing projects:
- tracing - The foundation of Rust structured logging
- tokio - Async runtime for Rust
- Sea-ORM - Async ORM for database operations
- axum - Web framework for HTTP endpoints
- serde - Serialization framework
- The entire Rust ecosystem for amazing tools and libraries
๐ Support
โญ Star History
๐ Support This Project
If you find this project useful, please consider giving it a โญ๏ธ!
Built with โค๏ธ by Inklog Team
ยฉ 2026 Inklog Project. All rights reserved.