-
-
Save tim-smart/614525 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var log = require('log'); | |
/** | |
* | |
* @returns | |
*/ | |
module.exports = { | |
server: { | |
address: '10.138.188.67', | |
port: 8000, | |
name: 'Imhotep', | |
timeout: '2000' | |
}, | |
logging_mode: log.mode.alpha, | |
logging_stream: log.mode.shell | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* @returns {log} | |
*/ | |
module.exports = { | |
mode: { | |
alpha: 0, | |
beta: 1, | |
gold: 2 | |
}, | |
stream: { | |
shell: 0, | |
file : 1, | |
both : 2, | |
email : 3 | |
}, | |
// Set by server.js | |
configuration: null, | |
message: function(message, level) { | |
level = typeof(level) != 'undefined' ? level : this.mode.alpha; | |
if(level >= this.configuration.logging_mode) { | |
var current_date = new Date(); | |
var hour = current_date.getHours(); | |
var period = 'am'; | |
if(current_date.getHours() > 12) { | |
hour -= 12; | |
period = 'pm'; | |
} | |
var milliseconds = parseInt((current_date.getTime() / 1000 - parseInt(current_date.getTime() / 1000)).toFixed(3) * 1000); | |
var output = '[' + | |
this.zeroFill(current_date.getMonth(), 2) + '/' + | |
this.zeroFill(current_date.getDate(), 2) + '/' + | |
(current_date.getYear() + 1900) + ' ' + | |
this.zeroFill(hour, 2) + ':' + | |
this.zeroFill(current_date.getMinutes(), 2) + ':' + | |
this.zeroFill(current_date.getSeconds(), 2) + '.' + | |
this.zeroFill(milliseconds, 3) + | |
period + '] ' + | |
message; | |
if(this.configuration.logging_stream == log.stream.shell) { | |
console.log(output); | |
} else if (this.configuration.logging_stream == log.stream.file) { | |
} else { | |
console.log(output); | |
} | |
} | |
}, | |
zeroFill: function(number, width) { | |
width -= number.toString().length; | |
if(width > 0) { | |
return new Array( width + (/\./.test( number ) ? 2 : 1) ).join( '0' ) + number; | |
} | |
return number; | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Modules | |
*/ | |
require.paths.unshift(__dirname + '/modules', __dirname); | |
var log = require('log'), | |
config = require('config'); | |
log.configuration = config; | |
/** | |
* Pre-Configuration Modules | |
*/ | |
var httpServer = new (require('httpServer'))(), | |
socketServer = new (require('socketServer'))(); | |
/** | |
* Main | |
*/ | |
httpServer.start(); | |
socketServer.start(httpServer); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment