Skip to content
This repository
Browse code

Tweak logging and error reporting.

This imports changes that were made against the live deployment
on the appsync preview machine.
  • Loading branch information...
commit 995ad5505089144cf83a01d9d983570981fc81bc 1 parent 8ab6e2b
Ryan Kelly rfk authored

Showing 2 changed files with 14 additions and 4 deletions. Show diff stats Hide diff stats

  1. +10 2 srv/main.js
  2. +4 2 srv/storage-thrift.js
12 srv/main.js
@@ -60,8 +60,10 @@ log4js.addAppender(log4js.consoleAppender());
60 60 log4js.addAppender(log4js.fileAppender('logs/sauropod.log'), 'sauropod');
61 61
62 62 var connect = require('connect');
  63 +console.log('Using the "' + conf + '" config');
63 64 var config = require('./configuration').getConfig(conf);
64 65 var logger = config.logger;
  66 +logger.info('Using the "' + conf + '" config');
65 67
66 68 console.log('Using the "' + config.storage.backend + '" storage backend');
67 69 var storage = require(config.storage.backend);
@@ -258,7 +260,8 @@ sauropod.put('/app/:appid/users/:userid/keys/:key', function(req, res) {
258 260 if (!err) {
259 261 res.send("OK", 200);
260 262 } else {
261   - res.send("Error " + err, 500);
  263 + //res.send("Error " + err, 500);
  264 + res.send(err.message, err.code);
262 265 }
263 266 });
264 267 }
@@ -278,6 +281,7 @@ sauropod.get('/app/:appid/users/:userid/keys/:key', function(req, res) {
278 281 data.bucket = verify["bucket"];
279 282 res.send(JSON.stringify(data), 200);
280 283 } else {
  284 + /*
281 285 if (404 == err.code ) {
282 286 res.send('Not found', 404);
283 287 }
@@ -286,6 +290,9 @@ sauropod.get('/app/:appid/users/:userid/keys/:key', function(req, res) {
286 290 // Log it
287 291 logger.error('storage.get failure "' + err + '" for ' + key + ': ' + JSON.stringify(err));
288 292 }
  293 + */
  294 + res.send(err.message, err.code);
  295 + logger.error('storage.get failure "' + err + '" for ' + key + ': ' + JSON.stringify(err));
289 296 }
290 297 });
291 298 }
@@ -296,7 +303,8 @@ sauropod.get('/__heartbeat__', function(req, res) {
296 303 if(!err) {
297 304 res.send("OK", 200);
298 305 } else {
299   - res.send("ERROR: storage is not accessible", 500);
  306 + //res.send("ERROR: storage is not accessible", 500);
  307 + res.send(err.message, err.code);
300 308 }
301 309 });
302 310 });
6 srv/storage-thrift.js
@@ -43,6 +43,7 @@ const crypto = require('crypto');
43 43 const config = require('./configuration').getConfig();
44 44
45 45 // Our client
  46 +config.logger.info("Connecting to thrift server: " + config.storage.host+':'+config.storage.port);
46 47 var conn = thrift.createConnection(config.storage.host, config.storage.port);
47 48 var client = thrift.createClient(hbase, conn);
48 49
@@ -136,8 +137,9 @@ function get(user, audience, key, cb) {
136 137 var http_err = morph_err(err, audience);
137 138 return cb(err, success);
138 139 } else {
139   - data.key = key;
140   - cb(err, data);
  140 + var data2 = data.shift() || { value: undefined, timestamp: -1 };
  141 + data2.key = key;
  142 + cb(err, data2);
141 143 }
142 144 });
143 145 }

0 comments on commit 995ad55

Please sign in to comment.
Something went wrong with that request. Please try again.