Keep secrets out of your AI agent's logs.
Safelog is a filter you drop into any pipe. It redacts API keys, tokens, private keys, emails, and IPs inline, one line at a time, so the stack trace you paste into Claude or Cursor never carries a live credential.
$ pip install "git+https://github.com/ctkrug/safelog"
What it does, and why it is different
Secret scanners like gitleaks and truffleHog scan a repo at rest in a batch job. Safelog does the other thing: it sits inline in a live pipe and redacts as bytes flow through, fast enough that a human or an agent on the other end never notices.
Sits in the pipe, not in your way
Reads stdin and writes stdout as each line arrives, with flat memory use no matter how long the stream runs. Measured at 60 to 125ms of added latency per 1000 lines, so a live tail -f stays responsive.
Knows secrets by their shape
Regex detectors for AWS keys, GitHub, GitLab and Slack tokens, Stripe keys, JWTs, multi-line PEM private key blocks, emails, and IPv4/IPv6. It redacts only the secret and keeps the env var name and timestamp around it, so the log still reads.
Catches the ones with no name
A Shannon-entropy fallback flags high-entropy tokens that no pattern would recognize, like a generic API key or a password. It runs only where a regex found nothing, so it never double-redacts a match.
Small enough to read and trust
Standard library only, no third-party dependencies. Vendor the package or install it in seconds. A tool that touches every byte of your logs should be short enough to read before you pipe secrets through it.
Redact your way
label names what was removed ([REDACTED:stripe-key]), mask hides even that (***), and hash gives a stable per-secret token so you can spot repeats without ever seeing the value.
Tune it to your logs
Disable any detector, add custom named patterns from a safelog.toml, or move the entropy threshold. Safe defaults mean cmd | safelog is useful with zero configuration.
One command, secrets gone
The same five log lines before and after Safelog. Timestamps, log levels, and structure survive. Only the secret spans get replaced.
raw stream (secrets exposed)
2026-07-17T12:00:01Z INFO starting worker pool=4 2026-07-17T12:00:02Z ERROR AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMIK7MDENGbP... 2026-07-17T12:00:03Z ERROR stripe key sk_test_NOTREALZZZ rejected 2026-07-17T12:00:04Z WARN contact jane.doe@example.com about quota 2026-07-17T12:00:05Z INFO client 10.0.4.212 connected
through safelog (secrets redacted)
2026-07-17T12:00:01Z INFO starting worker pool=4 2026-07-17T12:00:02Z ERROR AWS_SECRET_ACCESS_KEY=[REDACTED:aws-secret] 2026-07-17T12:00:03Z ERROR stripe key sk_test_[REDACTED:stripe-key] rejected 2026-07-17T12:00:04Z WARN contact [REDACTED:email] about quota 2026-07-17T12:00:05Z INFO client [REDACTED:ip] connected
Install and use
No config needed to start. Add flags when you want to change modes or turn detectors off.
install
# install the CLI (Python 3.9+) pip install "git+https://github.com/ctkrug/safelog" # or run without installing, from a clone PYTHONPATH=src python3 -m safelog < app.log
use it in a pipe
# live tail into an agent tail -f app.log | safelog | claude # scrub a command's output some-cli --verbose 2>&1 | safelog # mask instead of label; hide detector names cat crash.txt | safelog --mode mask # leave emails and IPs alone safelog --disable email --disable ip
Questions
What is Safelog for?
.env that a debug print dumped, an internal IP, a customer email. Safelog sits between that output and the agent and redacts the secrets before they leave your machine. It also fits a screen-share, a support ticket, or anything you paste into chat.How is it different from gitleaks or truffleHog?
| pipe without you noticing it. Different problem, different tool.Will it slow down my terminal?
What secrets does it catch?
safelog --list-detectors to see every name.