Permalink
Browse files

log streaming doesnt depend on autorefresh

  • Loading branch information...
jairajs89 committed Mar 7, 2013
1 parent 9f9cf11 commit 149d1d12d9ac8b84a72911336575cfd3aeefe112
Showing with 20 additions and 26 deletions.
  1. +1 −1 package.json
  2. +3 −7 run.js
  3. +16 −18 zerver.js
View
@@ -2,7 +2,7 @@
"author": "Jairaj Sethi <j@jairaj.org> (http://jairaj.org/)",
"name": "zerver",
"description": "client-integrated webapp server",
- "version": "0.8.3",
+ "version": "0.8.4",
"repository": {
"type": "git",
"url": "git://github.com/jairajs89/zerver.git"
View
10 run.js
@@ -175,13 +175,9 @@ function processFlags () {
REFRESH = false;
LOGGING = false;
}
- else {
- if (LOGGING) {
- REFRESH = true;
- }
- if (REFRESH) {
- DEBUG = true;
- }
+ else if (DEBUG || REFRESH || LOGGING) {
+ DEBUG = true;
+ PRODUCTION = false;
}
}
View
@@ -118,10 +118,7 @@ function configureZerver (port, apiDir, apiURL, apiHost, debug, refresh, logging
API_SCRIPT_MATCH = new RegExp('\\/'+API_URL+'\\/([^\\/]+)\\.js');
MANIFESTS = {};
- if (LOGGING) {
- REFRESH = true;
- }
- if (REFRESH) {
+ if (REFRESH || LOGGING) {
DEBUG = true;
}
@@ -1217,24 +1214,28 @@ function addCORSHeaders (headers, methods, host) {
function setupAutoRefresh () {
- if ( !app ) {
+ if (!app || !DEBUG || (!REFRESH && !LOGGING)) {
return;
}
var io = require('socket.io').listen(app, { log: false }),
sockets = io.of('/'+API_URL+'/_refresh');
- process.on('message', function (data) {
- if (data && data.debugRefresh) {
- sockets.emit('refresh');
- }
- });
+ if (REFRESH) {
+ process.on('message', function (data) {
+ if (data && data.debugRefresh) {
+ sockets.emit('refresh');
+ }
+ });
+ }
- sockets.on('connection', function (socket) {
- socket.on('log', function (data) {
- console.log(data.level + ': ' + data.message);
+ if (LOGGING) {
+ sockets.on('connection', function (socket) {
+ socket.on('log', function (data) {
+ console.log(data.level + ': ' + data.message);
+ });
});
- });
+ }
}
@@ -1243,8 +1244,5 @@ function setupAutoRefresh () {
if (require.main === module) {
exports.run(parseInt(process.argv[2]), process.argv[3], (process.argv[4]==='1'), (process.argv[5]==='1'), (process.argv[6]==='1'), (process.argv[7]==='1'), process.argv[8], (process.argv[9]==='1'), (process.argv[10]||undefined));
-
- if (DEBUG && REFRESH) {
- setupAutoRefresh();
- }
+ setupAutoRefresh();
}

0 comments on commit 149d1d1

Please sign in to comment.