Skip to content

Commit 0926345

Browse files
committed
Using bunyan-logger for requests
1 parent 1721c19 commit 0926345

File tree

3 files changed

+20
-23
lines changed

3 files changed

+20
-23
lines changed

lib/index.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,19 @@ var util = require('util');
44
var restify = require('restify');
55
var yaqs = require('yaqs');
66
var Childs = require('./helpers/Childs');
7+
var Logger = require("bunyan");
8+
var restifyBunyanLogger = require('restify-bunyan-logger');
79

810
var utils = require('./utils.js');
11+
12+
13+
// Create bunyan logger
14+
var log = new Logger.createLogger({
15+
name: process.env.APP_NAME || 'hydrater',
16+
});
17+
module.exports.log = log;
18+
19+
920
/**
1021
* Create a new hydration server.
1122
* This server will use `config.hydrater_function` as its main function, to turn a file into metadata.
@@ -43,12 +54,17 @@ module.exports.createServer = function(config) {
4354

4455
var hydraterHelper = require('./helpers/hydrater.js')(config.hydrater_function, childs, config.logger, config.errLogger);
4556

46-
var server = restify.createServer();
57+
var server = restify.createServer({
58+
log: log
59+
});
60+
61+
server.on('after', restifyBunyanLogger());
62+
4763
// Middleware Goes Here
64+
server.use(restify.requestLogger());
4865
server.use(restify.acceptParser(server.acceptable));
4966
server.use(restify.queryParser());
5067
server.use(restify.bodyParser());
51-
server.use(require('./middlewares/logger.js'));
5268

5369
server.yaqsClient = yaqs({
5470
prefix: config.hydraterUrl,

lib/middlewares/logger.js

Lines changed: 0 additions & 20 deletions
This file was deleted.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@
1818
],
1919
"dependencies": {
2020
"async": "^0.9.0",
21+
"bunyan": "^1.2.3",
2122
"opbeat": "^1.0.5",
2223
"rarity": "^2.1.1",
2324
"redis": "^0.12.1",
2425
"restify": "^2.8.3",
25-
"restify-logger": "^2.0.1",
26+
"restify-bunyan-logger": "^2.0.4",
2627
"supertest": "^0.14.0",
2728
"yaqs": "^1.0.3"
2829
},

0 commit comments

Comments
 (0)