Browse Source

log number of currently running games

romanmatiasko 10 years ago
parent
commit
8cac697d20
3 changed files with 15 additions and 5 deletions
  1. 2 1
      .gitignore
  2. 3 3
      package.json
  3. 10 1
      server.js

+ 2 - 1
.gitignore

@@ -1,3 +1,4 @@
 .DS_Store
 public/stylesheets/.sass-cache/
-node_modules/
+node_modules/
+logs/

+ 3 - 3
package.json

@@ -1,15 +1,15 @@
 {
   "name": "retichess",
-  "version": "0.0.2-0",
+  "version": "0.2.1",
   "scripts": {
     "start": "node server.js"
   },
   "dependencies": {
     "express": "~3.3.0",
     "jade": "~0.28.2",
-    "socket.io": "~0.9.16"
+    "socket.io": "~0.9.16",
+    "winston": "~0.7.3"
   },
-  "subdomain": "retichess",
   "engines": {
     "node": ">=0.8.x"
   }

+ 10 - 1
server.js

@@ -1,7 +1,8 @@
 var express = require('express')
   , path    = require('path')
   , crypto  = require('crypto')
-  , http    = require('http');
+  , http    = require('http')
+  , winston = require('winston');
 
 var app = express();
 
@@ -44,6 +45,12 @@ var server = http.createServer(app).listen(app.get('port'), app.get('ipaddress')
   console.log("Express server listening on port " + app.get('port'));
 });
 
+winston.add(winston.transports.File, { filename: 'logs/games.log', handleExceptions: true, exitOnError: false });
+winston.remove(winston.transports.Console);
+winston.handleExceptions(new winston.transports.Console());
+winston.exitOnError = false;
+
+
 var games = {};
 var timer;
 
@@ -115,6 +122,8 @@ io.sockets.on('connection', function (socket) {
     socket.emit('joined', {
       'color': color
     });
+
+    winston.log('info', 'Number of games', { '#': Object.keys(games).length });
   });
 
   socket.on('timer-white', function (data) {