log-tee
v1.0.1
Published
Run commands and log their output to a file while displaying in terminal (like Unix tee)
Downloads
26
Maintainers
Readme
log-tee
Run commands and log their output to a file while displaying in terminal (like Unix tee command).
Installation
You don't need to install it! Just use npx:
npx log-tee <logfile> <command> [args...]Or install globally:
npm install -g log-teeUsage
With npx (recommended)
npx log-tee output.log npm run devnpx log-tee build.log npm run buildnpx log-tee vite.log npm run dev-fullAfter global install
log-tee output.log npm run devFeatures
- Captures both stdout and stderr
- Displays output in real-time in the terminal
- Logs everything to a file simultaneously
- Adds timestamps to log entries
- Preserves exit codes
- Handles SIGINT/SIGTERM gracefully
- Preserves ANSI colors in terminal
- Works with any command
- Cross-platform: Windows, Mac, Linux
Examples
Run Vite dev server and log output:
npx log-tee vite.log npm run devRun tests and log results:
npx log-tee test-results.log npm testRun any command:
npx log-tee output.log node script.jsChain commands:
npx log-tee build.log sh -c "npm run build && npm run deploy"Why use log-tee?
- Debug issues locally: Keep logs of your dev or build processes
- Development: Monitor long-running processes while keeping a record
- No platform dependency: Works on Windows, Mac, and Linux
How it's different from shell redirection
Instead of:
npm run dev > output.log 2>&1 # No terminal output
npm run dev 2>&1 | tee output.log # Requires tee (not on all systems)Just use:
npx log-tee output.log npm run dev # Cross-platform, always worksLicense
MIT
