changeset 41:56767c69b7c4

added logging of chat with timestamps
author tzara <rc-web@kiben.net>
date Fri, 24 Aug 2012 16:07:30 +0000
parents 9d69c5b009e7
children 49c94f63b8b0
files nodescore.js www/index.html
diffstat 2 files changed, 23 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/nodescore.js	Thu Aug 23 16:17:31 2012 +0000
+++ b/nodescore.js	Fri Aug 24 16:07:30 2012 +0000
@@ -62,9 +62,31 @@
     });
    
 
+
+/// chat user messages to screens and to log file
+    
+    var da = new Date();
+    var dtstring = da.getFullYear()
+	+ '-' + da.getMonth()
+	+ '-' + da.getDate()
+    ;
+
+    fs.open('logs/chatlog-'+dtstring+'.txt', 'a', 666, function( e, id ) {	
+
     socket.on('user message', function (msg) {
+	var dt = new Date();var timestring = dt.getHours() + ':' + dt.getMinutes() + ':' + dt.getSeconds();
 	socket.broadcast.emit('user message', socket.nickname, msg);
+
+	////////////////////////
+	/// log messages to file
+
+	var fs = require('fs'), str = msg;
+	fs.write( id, timestring+" " + socket.nickname + ": "+ msg+"\n", null, 'utf8', function(){});
     });
+
+    });
+
+
     ////////////////////////////////////////////
     // metronome
     ////////////////////////////////////////////
--- a/www/index.html	Thu Aug 23 16:17:31 2012 +0000
+++ b/www/index.html	Fri Aug 24 16:07:30 2012 +0000
@@ -33,7 +33,7 @@
     
     <div align="left" class="readme" style="background:white; 
 					    color:black; 
-					    opacity:0.7;
+					    opacity:0.9;
 					    border-radius: 15px; 
 					    width:95%;
 					    margin:10px auto;
@@ -61,10 +61,6 @@
       NodeScore is written as a node.js web server incorporating websockets
       for server client communications.
       
-      <div style="padding: 10px 10px 10px 10px; border-radius:15px; background:transparent; width:400px; opacity:1; position:relative; z-index:11;">
-	<img  src="nodescore-client-20120823.png" width="300px">
-      </div>
-      
       <h3>Browser Compatability:</h3> 
       Modern Browsers only. No Internet Explorer support. Tested using Chromium.