https://github.com/riteek712/log-watcher-js
implementation of a log watcher file with help of WebSocket, it's a bare bone implementation of tail -f command from UNIX
https://github.com/riteek712/log-watcher-js
expressjs nodejs websocket
Last synced: 4 months ago
JSON representation
implementation of a log watcher file with help of WebSocket, it's a bare bone implementation of tail -f command from UNIX
- Host: GitHub
- URL: https://github.com/riteek712/log-watcher-js
- Owner: Riteek712
- Created: 2024-08-26T04:47:20.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-27T04:20:49.000Z (almost 2 years ago)
- Last Synced: 2025-01-02T22:46:03.312Z (over 1 year ago)
- Topics: expressjs, nodejs, websocket
- Language: JavaScript
- Homepage:
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# Log Watching Solution
This project implements a log-watching solution using Node.js. It consists of a WebSocket server that monitors a log file for updates and streams these updates to connected clients in real-time. The client-side is a simple web page that displays the log updates.
## Features
- **Server-Side:**
- Monitors a log file for changes.
- Streams new log entries to connected WebSocket clients.
- Sends the last 10 lines of the log file to new clients.
- **Client-Side:**
- Connects to the WebSocket server.
- Displays real-time log updates without refreshing the page.
## Usage
- The server will start on `ws://localhost:8080`.
- Open the `index.html` file in a web browser to view the log updates.
## Notes
- Make sure to adjust the `LOG_FILE_PATH` in `server.js` to point to the actual log file you want to monitor.
- The server will watch for file changes and push updates to all connected clients.
- The client-side JavaScript code handles WebSocket connections and updates the log display in real-time.
## Setup
1. **Clone the repository:**
```bash
git clone
cd log-watcher
```
2. **Install dependencies:**
```bash
npm install
```
3. **Create and populate the log file:**
```bash
touch logfile.log
```
4. **Run the server:**
```bash
node server.js
```
5. **Access the client:**
Open `index.html` in a web browser or serve it using a local HTTP server.
## License
This project is licensed under the MIT License.