Watchman is a system-level CLI utility written in C++ that continuously monitors a directory for filesystem changes. It detects when files or folders are created, modified, or deleted, records these events in a log file, and displays them in real time on the console.
The project focuses on operating-system interaction, not UI or business logic. It is designed to demonstrate how user-space programs can observe and react to OS-level filesystem events.
Watchman operates in user space and interacts with the operating system through native filesystem APIs.
- Uses OS-provided directory monitoring mechanisms (polling or event-based, depending on implementation)
- Continuously queries the filesystem state
- Compares snapshots to detect changes
- Reacts immediately when the OS reports a change
This makes Watchman a system utility, similar in nature to tools like tail -f or filesystem watchers.
-
Initial Scan
- Watchman scans the target directory at startup
- Stores metadata for each file (name, last modified time, size, etc.)
-
Monitoring Loop
- The program enters a continuous loop
- At regular intervals, the directory is re-checked
-
Change Detection
- New file β Created event
- Missing file β Deleted event
- Modified timestamp/size β Updated event
-
Event Trigger
- Once a change is detected, Watchman immediately:
- Writes the event to a log file
- Prints the event to the console
- Once a change is detected, Watchman immediately:
The watcher must remain in the root directory to maintain correct relative paths and logging behavior.
- All logs are stored in a file named:
watchman.log
- The log file is created automatically if it does not exist
- Logs are appended, not overwritten
Each entry contains:
- Timestamp
- Event type (CREATED / MODIFIED / DELETED)
- File or folder name
Example:
[2026-01-25 18:42:11] CREATED β notes.txt
[2026-01-25 18:43:02] MODIFIED β notes.txt
[2026-01-25 18:45:10] DELETED β old_data.csv
Watchman provides real-time console output while running:
- Every detected change is printed instantly
- Console output mirrors what is written to
watchman.log - This allows Watchman to be used both as:
- A background monitoring tool
- A real-time activity viewer
The program does not require restarting to see new events.
- Watchman is a long-running process
- It keeps executing until manually stopped
- Designed for terminal usage
- No GUI dependencies
For Watchman to function correctly, the executable must remain in the root directory being monitored:
Watchman/
βββ watchman.exe
βββ watchman.log
βββ monitored_files/
This ensures:
- Correct path resolution
- Consistent logging
- Predictable behavior across systems
Watchman qualifies as a system-level application because it:
- Interacts directly with OS filesystem services
- Monitors system resources
- Runs continuously
- Operates without user-facing UI layers
It demonstrates core system programming concepts using C++.
- File activity monitoring
- Debugging file changes
- Learning OS-level programming
- Understanding filesystem behavior
- Runs in user space (not kernel-level)
- Designed for learning and demonstration purposes
- No advanced filtering or configuration (by design)
Watchman is a lightweight, focused system utility that showcases how a C++ program can observe and react to filesystem changes using operating system facilities. It emphasizes clarity, simplicity, and direct OS interaction over complexity.