omni-logger v1.0.7
Omni Logger
Omni Logger is a simple console.log and console.error interceptor to provide a logger in real time in your browser.
There is no need to modify your current code and it aims to make easy to monitor the log on the server even when the application runs in the background (PM2, supervisor, screen, ...).
The logger runs on http://your-external-ip||localhost:port/omni-logger
Install
npm install omni-logger --save
Log all the things
The setup:
var omnilogger = require('omni-logger');
omnilogger.init([socketport], [expressport || expressobj], [options]);
The setup with port 5000 for socket and port 80 for http-server (express):
var omnilogger = require('omni-logger');
omnilogger.init(5000, 80);
Setup with options, port 5000 for socket, port 80 for http-server (express) and basic http auth (for the browser):
var omnilogger = require('omni-logger');
omnilogger.init(5000, 80, {auth: {user: 'foo', password: 'bar'}});
If localhost is undefined or false in options, it automatically fill the ip with your external ip (for dev you probably want localhost var to be true):
var omnilogger = require('omni-logger');
omnilogger.init(5000, 80, {localhost: true});
You can use your actual express server to handle the browser request, an example of external-ip fill, using http auth and the express instance:
var omnilogger = require('omni-logger');
var express = require('express');
var app = express();
omnilogger.init(5000, app, {localhost: false, auth: {user: 'foo', password: 'bar'}});
API
If you want to integrate the logger on your existing app, you can use http://socket.io to listen the logs:
var socket = io("http://your-ip:theport");
socket.on("log", function(msg){
//handle normal logs
});
socket.on("error", function(msg){
//handle error logs
});