Permalink
Browse files

Tweak logging and error reporting.

This imports changes that were made against the live deployment
on the appsync preview machine.
  • Loading branch information...
1 parent 8ab6e2b commit 995ad5505089144cf83a01d9d983570981fc81bc @rfk rfk committed Jan 27, 2012
Showing with 14 additions and 4 deletions.
  1. +10 −2 srv/main.js
  2. +4 −2 srv/storage-thrift.js
View
@@ -60,8 +60,10 @@ log4js.addAppender(log4js.consoleAppender());
log4js.addAppender(log4js.fileAppender('logs/sauropod.log'), 'sauropod');
var connect = require('connect');
+console.log('Using the "' + conf + '" config');
var config = require('./configuration').getConfig(conf);
var logger = config.logger;
+logger.info('Using the "' + conf + '" config');
console.log('Using the "' + config.storage.backend + '" storage backend');
var storage = require(config.storage.backend);
@@ -258,7 +260,8 @@ sauropod.put('/app/:appid/users/:userid/keys/:key', function(req, res) {
if (!err) {
res.send("OK", 200);
} else {
- res.send("Error " + err, 500);
+ //res.send("Error " + err, 500);
+ res.send(err.message, err.code);
}
});
}
@@ -278,6 +281,7 @@ sauropod.get('/app/:appid/users/:userid/keys/:key', function(req, res) {
data.bucket = verify["bucket"];
res.send(JSON.stringify(data), 200);
} else {
+ /*
if (404 == err.code ) {
res.send('Not found', 404);
}
@@ -286,6 +290,9 @@ sauropod.get('/app/:appid/users/:userid/keys/:key', function(req, res) {
// Log it
logger.error('storage.get failure "' + err + '" for ' + key + ': ' + JSON.stringify(err));
}
+ */
+ res.send(err.message, err.code);
+ logger.error('storage.get failure "' + err + '" for ' + key + ': ' + JSON.stringify(err));
}
});
}
@@ -296,7 +303,8 @@ sauropod.get('/__heartbeat__', function(req, res) {
if(!err) {
res.send("OK", 200);
} else {
- res.send("ERROR: storage is not accessible", 500);
+ //res.send("ERROR: storage is not accessible", 500);
+ res.send(err.message, err.code);
}
});
});
View
@@ -43,6 +43,7 @@ const crypto = require('crypto');
const config = require('./configuration').getConfig();
// Our client
+config.logger.info("Connecting to thrift server: " + config.storage.host+':'+config.storage.port);
var conn = thrift.createConnection(config.storage.host, config.storage.port);
var client = thrift.createClient(hbase, conn);
@@ -136,8 +137,9 @@ function get(user, audience, key, cb) {
var http_err = morph_err(err, audience);
return cb(err, success);
} else {
- data.key = key;
- cb(err, data);
+ var data2 = data.shift() || { value: undefined, timestamp: -1 };
+ data2.key = key;
+ cb(err, data2);
}
});
}

0 comments on commit 995ad55

Please sign in to comment.