taildir
v1.1.3
Published
A simple directory watcher that recursively monitors file changes using only native Node.js libraries
Maintainers
Readme
taildir
A lightweight Node.js directory watcher that monitors file changes recursively and outputs new content as it's appended - similar to tail -f but for entire directories.
Features
- Recursively watches all files in a directory tree
- Outputs only new content when files grow (like
tail -f) - Filter by file extensions (e.g., watch only
.logfiles) - Ignores hidden files and temporary files
- Lightweight - uses only native Node.js libraries
- Trims empty lines from output
Installation
npm install -g taildirOr run directly with npx:
npx taildir <directory>Usage
Watch the current directory:
taildirWatch a specific directory:
taildir /path/to/directoryWatch only specific file extensions:
taildir /path/to/directory -e js,ts,json
taildir --ext log,txtExample Output
Starting to watch: /home/user/logs
Press Ctrl+C to stop
==> /home/user/logs/app.log <==
[2024-01-15 10:30:45] Application started
[2024-01-15 10:30:46] Connected to database
==> /home/user/logs/error.log <==
[2024-01-15 10:31:02] ERROR: Failed to process requestHow It Works
- When starting,
taildirrecords the current size of all files - When a file grows, it reads and displays only the new content
- New files created while watching will show their complete content
- Files that shrink (truncated) are tracked but don't produce output
- Hidden files (starting with
.) are ignored
Use Cases
- Monitor application logs across multiple files
- Watch output directories for generated content
- Track changes in data files
- Debug file-writing applications
Requirements
- Node.js >= 14.0.0
License
MIT
