A lightweight TypeScript-based CLI tool to clean noisy log files and keep only meaningful entries. Simple usage, multiple log formats, and sane defaults for real-world debugging.
- 🔍 Log level filtering (
INFO,WARN,ERROR,FATAL, etc.) - 🧠 Severity-based matching
ERRORshowsERROR + FATAL,WARNshowsWARN + ERROR + FATAL - 📄 Multiple log formats supported (auto-detected)
- Simple logs (
2026-01-12 ERROR something broke) - Pipe/enterprise logs (
| Info | Service | ...)
- Simple logs (
- 🔄 Context lines before/after matching logs
- 🪄 Auto-detect log format (no flags needed)
- 🖥️ Works on Windows / macOS / Linux
- Node.js v18+
- npm
npm installnpm run dev -- your.log -- --level ERROR --context 1
⚠️ Note for Windows users: when usingnpm run, you must add a second--before CLI flags.
npm run buildnpm linkThen you can run:
log-clean your.log --level ERRORlog-clean <file> [options]| Option | Description | Default |
|---|---|---|
-l, --level <level> |
Minimum log level | ERROR |
-c, --context <n> |
Lines before/after the matched log | 0 |
-o, --output <file> |
Output file name | cleaned.log |
log-clean app.log --level ERROROutput includes:
ERROR
FATAL
log-clean app.log --level WARN --context 1Shows WARN, ERROR, FATAL logs plus surrounding lines that also match severity rules.
The tool supports multiple log formats implicitly, without requiring explicit configuration. As long as a log line contains a recognizable log level, it can be filtered.
Below are the officially supported formats with example log lines for each log level.
Common in many backend services and scripts.
2026-01-12 DEBUG Token refreshed
2026-01-12 INFO App started
2026-01-12 WARN Slow response
2026-01-12 ERROR Payment failed
2026-01-12 FATAL System crashed
Often seen in enterprise or agent-based systems.
2026-01-13 21:58:26.4614 | DEBUG | TEST | Debug message
2026-01-13 21:58:26.4614 | INFO | TEST | Information message
2026-01-13 21:58:26.4614 | WARN | TEST | Warning message
2026-01-13 21:58:26.4614 | ERROR | TEST | Error message
2026-01-13 21:58:26.4614 | FATAL | TEST | Fatal error message
Common in Go applications with structured logging and caller information.
[2023/10/12 22:06:47 +03] [DEBUG] (pkg/logger.Debug:12) Debugging startup sequence
[2023/10/12 22:06:47 +03] [INFO] (pkg/logger.Info:34) Application started
[2023/10/12 22:06:47 +03] [WARN] (pkg/logger.Warn:56) Configuration file missing, using defaults
[2023/10/12 22:06:52 +03] [ERROR] (pkg/logger.Error:78) Failed to connect to database
[2023/10/12 22:06:52 +03] [FATAL] (pkg/logger.Fatal:91) Unrecoverable error, shutting down
Nested logs inside pipe sections are also supported:
[2023/10/12 22:06:52 +03] [ERROR] (pkg/logger.Error:78) ENGINE | [10/12/23 22:06:52] [ERROR] inner component failure
Widely used in Java and JVM-based applications.
2026-01-12 21:58:26,461 DEBUG [main] com.app.Service - Debug message
2026-01-12 21:58:26,461 INFO [main] com.app.Service - Application started
2026-01-12 21:58:26,461 WARN [main] com.app.Service - Deprecated API usage
2026-01-12 21:58:26,461 ERROR [main] com.app.Service - Payment failed
2026-01-12 21:58:26,461 FATAL [main] com.app.Service - JVM crash detected
Default or customized Python logging module output.
2026-01-12 21:58:26,461 - DEBUG - worker - Debug message
2026-01-12 21:58:26,461 - INFO - worker - Task started
2026-01-12 21:58:26,461 - WARN - worker - Retry attempt
2026-01-12 21:58:26,461 - ERROR - worker - Task failed
2026-01-12 21:58:26,461 - FATAL - worker - Worker crashed
Common in Linux servers and infrastructure logs.
Jan 12 21:58:26 server1 DEBUG sshd[1234]: Debugging SSH key exchange
Jan 12 21:58:27 server1 INFO sshd[1234]: Accepted password for user from 192.168.1.10
Jan 12 21:58:28 server1 WARN sshd[1234]: Authentication attempt failed for invalid user
Jan 12 21:58:29 server1 ERROR sshd[1234]: Failed to read authorized_keys file
Jan 12 21:58:30 server1 FATAL sshd[1234]: Critical failure, sshd shutting down
- Cleaner logic is independent of log format
- Parsers are extensible and isolated
npm run dev
npm run buildProject structure:
src/
├─ index.ts # CLI entry point
├─ cleaner.ts # Core filtering logic
├─ logEntry.ts # Shared log model
├─ types.ts # Log levels & enums
└─ parsers/
├─ AutoParser.ts
├─ SimpleParser.ts
├─ PipeParser.ts
└─ LogParser.ts
Happy log cleaning 🧘♀️