abhishekg785 / Log-File-Viewer

Simple File viewer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Log File Viewer
---------------

A simple web app in Node.JS, that fetches the logs from the log file at the server and displays the fetched data to the clint 10 records at a time.

Considering the file size is too large , reading the file as a whole is not a good approach, as it will consume
                -----------------------
a lot of memory or RAM.

So the Node.JS Streams comes to the rescue.
      -----------------
Reading chunks of data at a given time rather than the whole file will take less memory.

This can be further optimized if i read only the desired data from the file, rather than
reading the unnecessary part of the file to the initial required position ( start position ).

This can be done using offsets in file, i.e keeping records of the start/end offset in the file,
and then start reading from the required start offset to the end offset and keep repeating the steps.

Porblems Occurred :
-------------------

It works fine when it comes to :
      - reading the next 10 records each time from the file
      - reading the last 10 records
      - reading start 10 records

but problem occurs when it comes to reading previous 10 records as the chunk size is variable each time and
going back to the previous 10 records becomes quite messy.

However working on it ! Maybe i get some solution for that.

Steps to Run :
1. cd into the project dir
2. do 'sudo npm install' to install npm modules
3. node bin/www

This will start the server at port 3000
Go to localhost:3000 on the browser.

Testing
-------

I have used the following tools for testing :
Mocha  : for testing
Chai   : for assertion
Sinon  : for stubs and spies implementations

The test cases are present on the test folder inside the project dir.
i.e /test

The test dir also contains a test file to be used in testing.

This is how to run the test cases :

for the main.js file ( /app/public/js/main.js)

    - Simply open the file testRunner.html file in the browser and it will run the test cases for the main.js file.

for the node js modules :

    - Simply run the command => npm run test
    This will run all the test files present in the test folder.

About

Simple File viewer


Languages

Language:JavaScript 65.0%Language:HTML 25.3%Language:CSS 9.7%