Add timestamps to chat logs

This commit is contained in:
Guangcong Luo
2013-08-31 17:04:59 -05:00
parent 46de389961
commit a399e19e28

View File

@@ -88,10 +88,19 @@ _Storage.prototype.nwLogChat = function(roomid, line) {
streams[i].end();
}
}
var now = new Date();
var hours = ''+now.getHours();
if (hours.length < 2) hours = '0'+hours;
var minutes = ''+now.getHours();
if (minutes.length < 2) minutes = '0'+minutes;
var timestamp = '['+hours+':'+minutes+'] ';
if (!this.chatLogStreams[roomid]) {
this.chatLogStreams[roomid] = fs.createWriteStream(this.dir+'Logs/'+chatLogFdMonth+'/'+roomid+'.txt', {flags:'a'});
this.chatLogStreams[roomid].write('\n\n\nLog starting '+now+'\n\n');
}
this.chatLogStreams[roomid].write(line+'\n');
this.chatLogStreams[roomid].write(timestamp+line+'\n');
};
// saving