Implement Winston powered logger
This commit is contained in:
17
lib/logger.js
Normal file
17
lib/logger.js
Normal file
@ -0,0 +1,17 @@
|
||||
var winston = require('winston');
|
||||
|
||||
winston.remove(winston.transports.Console);
|
||||
|
||||
winston.add(winston.transports.File, {
|
||||
filename: 'minetrack.log'
|
||||
});
|
||||
winston.add(winston.transports.Console, {
|
||||
'timestamp': function() {
|
||||
var date = new Date();
|
||||
|
||||
return date.toLocaleTimeString() + " " + date.getDate() + "/" + (date.getMonth() + 1) + "/" + date.getFullYear().toString().substring(2, 4);
|
||||
},
|
||||
'colorize': true
|
||||
});
|
||||
|
||||
module.exports = winston;
|
@ -4,6 +4,8 @@ var url = require('url');
|
||||
var mime = require('mime');
|
||||
var io = require('socket.io');
|
||||
|
||||
var logger = require('./logger');
|
||||
|
||||
var config = require('../config.json');
|
||||
|
||||
exports.start = function(callback) {
|
||||
@ -15,7 +17,7 @@ exports.start = function(callback) {
|
||||
urlMapping[routeKeys[i]] = config.routes[routeKeys[i]];
|
||||
}
|
||||
|
||||
console.log(Object.keys(config.routes));
|
||||
logger.log('info', Object.keys(config.routes));
|
||||
|
||||
// Create our tiny little HTTP server.
|
||||
var server = http.createServer(function(req, res) {
|
||||
@ -41,7 +43,7 @@ exports.start = function(callback) {
|
||||
exports.io = (io = io.listen(server));
|
||||
|
||||
// Since everything is loaded, do some final prep work.
|
||||
console.log('Started on %s:%d', config.site.ip, config.site.port);
|
||||
logger.log('info', 'Started on %s:%d', config.site.ip, config.site.port);
|
||||
|
||||
callback();
|
||||
};
|
Reference in New Issue
Block a user