📜 ⬆️ ⬇️

PuperGrep - real-time browser logs

You do not like to watch the logs in the console or you do not allow them to love, but somehow you need to monitor the progress of affairs?

PuperGrep is a log viewer in a browser that works like tail -F , grep and highlights the most interesting things in your browser. Or even on your android, iPhone or iPad.

Screenshot PuperGrep
')


Opportunities





Impossibility





Using



All good is written on node.js + socket.io + twitter bootstrap.

To start, we execute the following commands:

 mkdir ~ / mypupergrep
 cd ~ / mypupergrep
 mkdir node_modules
 npm install pupergrep


Because pupergrep is just a npm module, we will need to write a simple server and save it in ~ / mypupergrep / server.js :

 (function () {
     var PuperGrep = require ("pupergrep"),
         puper = new PuperGrep (),
         manager = puper.getLogReaderManager ();

     // here my_cool_log is the name of the log, and / var / log / my_cool_log is the path to it
     manager.addLog ("my_cool_log", "/ var / log / my_cool_log", function (error) {
         if (error) {
             console.log ("Error adding test log", error);
             return;
         }

         // if your log may be interpreted as html:
         // manager.setLogType ("my_cool_log", "html");

         puper.listen (8080, "127.0.0.1");
     });
 }) ();


Run by the command:

 node server.js


Now at http://127.0.0.1:8080/ your own PuperGrep will be visible with the my_cool_log log.

If you use in production, it is reasonable to put nginx in front of your server, which will deal with user authorization or even static distribution. This is on the project page . It should be noted that nginx does not support websockets (for the time being) and you have to wait a couple of seconds each time you open the page to switch to xhr-polling.

The end of the ends



On the project page on Github you can read more. You can also leave your pull request, I will only be glad.

Demo , only uptime log is actively written there.

Source: https://habr.com/ru/post/150085/


All Articles