Skip to content
This repository has been archived by the owner on Aug 22, 2019. It is now read-only.

Commit

Permalink
Use messina module
Browse files Browse the repository at this point in the history
  • Loading branch information
stenington committed Sep 23, 2013
1 parent 56ff5f4 commit 1903ff2
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 162 deletions.
111 changes: 0 additions & 111 deletions bin/messina

This file was deleted.

26 changes: 3 additions & 23 deletions lib/logger.js
@@ -1,23 +1,3 @@
const bunyan = require('bunyan');

const log = module.exports = bunyan.createLogger({
name: 'openbadges-backpack',
stream: process.stdout,
level: 'info',
serializers: {
req: bunyan.stdSerializers.req,
res: bunyan.stdSerializers.res
}
});

// Patch console so it only outputs to stderr
require('./console-patch');

// Normal uncaught exception handling outputs the stacktrace to the
// console before exiting with a non-zero status. This is *almost* what
// we want, except we also want to make sure it ends up in the
// application's event stream as a fatal event.
process.once('uncaughtException', function (err) {
log.fatal(err);
throw err;
});
const messina = require('messina');
const log = module.exports = messina('openbadges-backpack');
log.init();
27 changes: 1 addition & 26 deletions middleware.js
Expand Up @@ -30,32 +30,7 @@ exports.cookieSessions = function cookieSessions() {
});
};

var requestLogger = function requestLogger(req, res, next) {
const startTime = new Date();
logger.info({
req: req
}, util.format(
'Incoming Request: %s %s',
req.method, req.url));

// this method of hijacking res.end is inspired by connect.logger()
// see connect/lib/middleware/logger.js for details
const end = res.end;
res.end = function(chunk, encoding) {
const responseTime = new Date() - startTime;
res.end = end;
res.end(chunk, encoding);
logger.info({
url: req.url,
responseTime: responseTime,
res: res,
}, util.format(
'Outgoing Response: HTTP %s %s (%s ms)',
res.statusCode, req.url, responseTime));
};
return next();
};

const requestLogger = logger.middleware();
const imgPrefix = '/images/badge/';
exports.logRequests = function logRequests() {
return function (req, res, next) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -5,7 +5,7 @@
"private": true,
"scripts": {
"test": "NODE_ENV=test ./node_modules/.bin/tap-prettify test/*.test.js",
"start": "./bin/db-migrate up && ./node_modules/.bin/up -w -n 1 -p 8888 app.js | ./node_modules/.bin/bunyan"
"start": "./bin/db-migrate up && ./node_modules/.bin/up -w -n 1 -p 8888 app.js | bunyan"
},
"devDependencies": {
"jshint": "~0.6.2",
Expand Down Expand Up @@ -34,7 +34,7 @@
"openbadges-bakery": "0.2.6",
"newrelic": "~0.10.3",
"async": "~0.2.6",
"bunyan": "~0.21.4",
"messina": "~0.1.0",
"gelf-stream": "~0.2.2",
"request": "~2.27.0",
"node-statsd": "~0.0.7"
Expand Down

0 comments on commit 1903ff2

Please sign in to comment.