@@ -4,8 +4,19 @@ var util = require('util');
44var restify = require ( 'restify' ) ;
55var yaqs = require ( 'yaqs' ) ;
66var Childs = require ( './helpers/Childs' ) ;
7+ var Logger = require ( "bunyan" ) ;
8+ var restifyBunyanLogger = require ( 'restify-bunyan-logger' ) ;
79
810var 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 ,
0 commit comments