A CLI tool written in Rust that scans JSON log files in a repository and sends WARN/ERROR/CRITICAL log entries to Sentry.
- Recursively scans directories for JSON log files
- Parses log entries in the format used by Python's Loguru logger
- Filters for WARNING, ERROR, and CRITICAL log levels
- Sends matching entries to Sentry with full context
- Supports dry-run mode for testing
- Can read Sentry DSN from environment variable
Make sure you have Rust installed (https://rustup.rs/), then:
cd sentry-log-scanner
cargo build --releaseThe binary will be available at target/release/sentry-log-scanner.
# Basic usage
./sentry-log-scanner --path /path/to/logs --dsn "https://your-sentry-dsn@sentry.io/project"
# Using environment variable for DSN
export SENTRY_DSN="https://your-sentry-dsn@sentry.io/project"
./sentry-log-scanner --path /path/to/logs
# Dry run mode (doesn't send to Sentry, just lists found entries)
./sentry-log-scanner --path /path/to/logs --dsn "https://your-dsn@sentry.io/project" --dry-run| Option | Short | Description | Required |
|---|---|---|---|
--path |
-p |
Path to directory containing log files | Yes |
--dsn |
-d |
Sentry DSN (can also use SENTRY_DSN env var) | Yes |
--dry-run |
Test mode - don't send to Sentry | No |
The tool expects JSON log files where each line is a JSON object with the following structure:
{
"text": "2025-11-25 18:03:13.318 | WARNING | logging:callHandlers:1762 - timeout message\n",
"record": {
"level": {
"name": "WARNING",
"no": 30
},
"message": "timeout message",
"time": {
"repr": "2025-11-25 18:03:13.318918+08:00",
"timestamp": 1764064993.318918
},
"file": {
"name": "__init__.py",
"path": "/path/to/file.py"
},
"function": "functionName",
"line": 123,
"module": "moduleName"
}
}This format is compatible with Python's Loguru logger when configured with JSON serialization.
Each Sentry event includes:
- Level: WARNING, ERROR, or FATAL (mapped from CRITICAL)
- Message: The log message
- Logger: The module name
- Extra data:
source_file: Path to the JSON log fileoriginal_file: Original Python file that generated the logfunction: Function nameline: Line numberlog_text: Full text representation of the log entryoriginal_timestamp: Original timestamp from the log
Scanning directory: "/path/to/logs"
Sentry DSN: https://your-dsn@...
Dry run: false
[WARNING] 2025-11-25 18:03:13.318918+08:00 - timeout waiting for GET_LIMIT_SWITCH after 0.15s (__init__.py:1762)
[ERROR] 2025-11-25 18:04:00.123456+08:00 - Connection failed (defs.py:100)
--- Summary ---
Files scanned: 100
WARN/ERROR/CRITICAL entries found: 42
Events sent to Sentry: 42
MIT