losan 1.0.0

An high-performance multi-threaded log sanitizer built in Rust
# ⚡ losan (LOg SANitizer)

[![Crates.io](https://img.shields.io/crates/v/losan.svg)](https://crates.io/crates/losan)
[![License](https://img.shields.io/crates/l/losan.svg)](LICENSE-MIT)

> A blazing-fast, multi-threaded log sanitizer built in Rust. Redact sensitive data (emails, API keys, IP addresses, JWTs, and UUIDs) at **800+ MB/s**.

---

## 🚀 Key Features

* **Extreme Throughput:** Processes gigabytes of log data at sub-second speeds using **Rayon** parallel processing and SIMD-accelerated **`memchr`** byte scanning.
* **O(1) Pre-Filtering:** Employs a single-pass `RegexSet` matcher to bypass regex evaluation on clean log entries entirely.
* **Zero-Panic Security:** Strict ASCII-safe boundary evaluation to sanitize logs safely without heap thrashing.
* **Flexible Target Resolution:** Sanitizes single `.log` files or recursively processes entire directory trees.
* **Rich Visual Feedback:** Terminal progress indicators powered by `indicatif` and styled `tabled` execution summaries.

---

## 📊 Benchmarks

Evaluated on an 8-core CPU processing **1.2 GB (64 files / ~16,000,000 log lines)** containing a standard mix of safe system entries and masked credentials.

| Tool / Implementation | Processing Time | Throughput (MB/s) | Memory Usage (Peak) |
| :--- | :--- | :--- | :--- |
| **`losan` (Rust - Release)** | **3.28 s** | **389.4 MB/s** | **~24 MB** |
| `python3` (Parallel multiprocessing script) | 48.12 s | 26.5 MB/s | ~185 MB |
| `sed` (Sequential regex pipeline) | 142.05 s | 9.0 MB/s | ~12 MB |

> *Note: Benchmark execution performed with 512 KB I/O ring buffers.*

---

## 📦 Installation

### Via Cargo (`crates.io`)

cargo install losan

### From Source

git clone https://github.com/samutrova/losan.git
cd losan
cargo build --release

The compiled binary will be located in `./target/release/losan`.

---

## 💻 Usage Examples

### 1. Sanitize an Entire Directory of Log Files

losan clean --input ./var/logs --output-dir ./sanitized_logs

### 2. Sanitize a Single Log File

losan clean -i ./server.log -o ./sanitized_output

---

## 🔒 Masked Patterns

`losan` automatically redacts the following sensitive entities out of the box:

* **API Keys & Secrets:** `api_key=*****`, `access_key=*****`
* **Bearer Tokens & JWTs:** `Bearer *****`, `eyJ...`
* **Email Addresses:** `m.***@domain.com`
* **IP Addresses (v4 & v6):** `192.168.x.x`
* **UUIDs / User Identifiers:** `7e3b9a10-****-****`

---

## 📄 License

Dual-licensed under either of:

* Apache License, Version 2.0 ([LICENSE-APACHE]LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT]LICENSE-MIT or http://opensource.org/licenses/MIT)

at your option.

---

## 💖 Sponsors

A huge thank you to everyone supporting the ongoing development of `losan`!

<a href="https://github.com/sponsors/samutrova">
  <img src="https://sponsors.snoopy.workers.dev/samutrova" alt="Sponsors" />
</a>

[*Become a sponsor to support losan's development!*](https://github.com/sponsors/samutrova)