Colors in log (if dev)

This commit is contained in:
Thomas FORGIONE 2015-07-03 11:57:45 +02:00
parent 3c11aba194
commit e8af26913e
2 changed files with 15 additions and 3 deletions

View File

@ -38,9 +38,11 @@ app.use(function(req, res, next) {
// Log connection // Log connection
console.log( console.log(
(isDev ? '\033[32m' : '') +
'[REQ] ' + new Date() + ' ' + '[REQ] ' + new Date() + ' ' +
(req.headers['x-forwarded-for'] || req.connection.remoteAddress) + (req.headers['x-forwarded-for'] || req.connection.remoteAddress) +
' : ' + req.url ' : ' + req.url +
(isDev ? '\033[0m' : '')
); );
res.locals.title = "3DUI"; res.locals.title = "3DUI";

View File

@ -1,13 +1,23 @@
var fs = require('fs'); var fs = require('fs');
var geo = require('./lib/geo.min.js'); var geo = require('./lib/geo.min.js');
var isDev = require('express')().get('env') === 'development';
module.exports = function(io) { module.exports = function(io) {
io.on('connection', function(socket) { io.on('connection', function(socket) {
console.log('[SOK] ' + new Date() + ' ' + socket.handshake.address + ' connection'); console.log(
(isDev ? '\033[33m' : '') +
'[SOK] ' + new Date() + ' ' + socket.handshake.address + ' connection' +
(isDev ? '\033[0m' : '')
);
socket.on('disconnect', function() { socket.on('disconnect', function() {
console.log('[SOK] ' + new Date() + ' ' + socket.handshake.address + ' disconnect'); console.log(
(isDev ? '\033[34m' : '') +
'[SOK] ' + new Date() + ' ' + socket.handshake.address + ' disconnect' +
(isDev ? '\033[0m' : '')
);
}); });
var streamer = new geo.MeshStreamer(); var streamer = new geo.MeshStreamer();