Changed logger
This commit is contained in:
		
							parent
							
								
									c9bfc2dedd
								
							
						
					
					
						commit
						24765a4687
					
				| @ -45,7 +45,7 @@ Log.socket.connection = function(socket) { | ||||
|     log( | ||||
|         '[SOK] ' + new Date() + ' ' + | ||||
|         socket.handshake.address + ' connection', | ||||
|         Colors.YELLOW | ||||
|         Colors.MAGENTA | ||||
|     ); | ||||
| }; | ||||
| 
 | ||||
| @ -53,7 +53,7 @@ Log.socket.disconnect = function(socket) { | ||||
|     log( | ||||
|         '[SOK] ' + new Date() + ' ' + | ||||
|         socket.handshake.address + ' disconnect', | ||||
|         Colors.YELLOW | ||||
|         Colors.MAGENTA | ||||
|     ); | ||||
| }; | ||||
| 
 | ||||
| @ -64,4 +64,15 @@ Log.dberror = function(error) { | ||||
|     ); | ||||
| }; | ||||
| 
 | ||||
| if (isDev) { | ||||
|     Log.debug = function(info) { | ||||
|         log( | ||||
|             '[DBG] ' + (info !== undefined ? info : ''), | ||||
|             Colors.YELLOW | ||||
|         ); | ||||
|     }; | ||||
| } else { | ||||
|     Log.debug = function(){}; | ||||
| } | ||||
| 
 | ||||
| module.exports = Log; | ||||
|  | ||||
| @ -4,12 +4,11 @@ | ||||
| 
 | ||||
| var express = require('express'); | ||||
| var fs = require('fs'); | ||||
| var Log = require('./NodeLog.js'); | ||||
| 
 | ||||
| module.exports = function(parent, options){ | ||||
|     var verbose = options.verbose; | ||||
| module.exports = function(parent){ | ||||
| 
 | ||||
|     if (verbose) | ||||
|         console.log("Loading controllers :"); | ||||
|     Log.debug("Loading controllers :"); | ||||
| 
 | ||||
|     fs.readdirSync(__dirname + '/../controllers').forEach(function(name){ | ||||
| 
 | ||||
| @ -28,19 +27,16 @@ module.exports = function(parent, options){ | ||||
|         // generate routes based
 | ||||
|         // on the exported methods
 | ||||
| 
 | ||||
|         if (verbose) | ||||
|             console.log('\t' + name + ':'); | ||||
|         Log.debug('   ' + name + ':'); | ||||
| 
 | ||||
|         for (var key in urls) { | ||||
|             app.get(key, obj[urls[key]]); | ||||
| 
 | ||||
|             if (verbose) | ||||
|                 console.log('\t\t' + key + ' -> ' + name + '.' + urls[key]); | ||||
|             Log.debug('      ' + key + ' -> ' + name + '.' + urls[key]); | ||||
| 
 | ||||
|         } | ||||
| 
 | ||||
|         if (verbose) | ||||
|             console.log(); | ||||
|         Log.debug(); | ||||
| 
 | ||||
|         // mount the app
 | ||||
|         parent.use(app); | ||||
|  | ||||
							
								
								
									
										16
									
								
								lib/posts.js
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								lib/posts.js
									
									
									
									
									
								
							| @ -4,12 +4,11 @@ | ||||
| 
 | ||||
| var express = require('express'); | ||||
| var fs = require('fs'); | ||||
| var Log = require('./NodeLog.js'); | ||||
| 
 | ||||
| module.exports = function(parent, options){ | ||||
|     var verbose = options.verbose; | ||||
| module.exports = function(parent){ | ||||
| 
 | ||||
|     if (verbose) | ||||
|         console.log("Loading controllers :"); | ||||
|     Log.debug("Loading controllers :"); | ||||
| 
 | ||||
|     fs.readdirSync(__dirname + '/../posts').forEach(function(name){ | ||||
| 
 | ||||
| @ -28,18 +27,15 @@ module.exports = function(parent, options){ | ||||
|         // generate routes based
 | ||||
|         // on the exported methods
 | ||||
| 
 | ||||
|         if (verbose) | ||||
|             console.log('\t' + name + ':'); | ||||
|         Log.debug('   ' + name + ':'); | ||||
| 
 | ||||
|         for (var key in urls) { | ||||
|             app.post(key, obj[urls[key]]); | ||||
| 
 | ||||
|             if (verbose) | ||||
|                 console.log('\t\t' + key + ' -> ' + name + '.' + urls[key]); | ||||
|             Log.debug('      ' + key + ' -> ' + name + '.' + urls[key]); | ||||
|         } | ||||
| 
 | ||||
|         if (verbose) | ||||
|             console.log(); | ||||
|         Log.debug(); | ||||
| 
 | ||||
|         // mount the app
 | ||||
|         parent.use(app); | ||||
|  | ||||
| @ -59,10 +59,10 @@ app.use(function(req, res, next) { | ||||
| }); | ||||
| 
 | ||||
| // Load controllers
 | ||||
| require('./lib/controllers')(app, { verbose: isDev }); | ||||
| require('./lib/controllers')(app); | ||||
| 
 | ||||
| // Load post to log data from user study
 | ||||
| require('./lib/posts')(app, { verbose: isDev }); | ||||
| require('./lib/posts')(app); | ||||
| 
 | ||||
| // Static files
 | ||||
| app.use('/static', express.static('static')); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user