Skip to content

Commit

Permalink
Merge pull request #4 from mpal9000/patch-1
Browse files Browse the repository at this point in the history
Named middleware
  • Loading branch information
aheckmann committed Jan 13, 2015
2 parents 75e67b3 + 48ef577 commit ffc5765
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ function createOrUseLogger(logger) {
* containing a bunyan logger instance.
*
* Parameters:
* - logger: bunyan logger instance, or an object with properties
* that will be passed to bunyan.createLogger. If not
* specified, a default logger will be used.
* - loggerInstance: bunyan logger instance, or an object with properties
* that will be passed to bunyan.createLogger. If not
* specified, a default logger will be used.
*/
module.exports = function (logger) {
logger = createOrUseLogger(logger);
module.exports = function (loggerInstance) {
loggerInstance = createOrUseLogger(loggerInstance);

return function *(next) {
this.log = logger;
return function *logger(next) {
this.log = loggerInstance;

yield *next; // jshint ignore:line
};
Expand Down Expand Up @@ -63,7 +63,7 @@ module.exports.requestIdContext = function (opts) {
var logField = opts.field || 'req_id';
var fallbackLogger;

return function * (next) {
return function *requestIdContext(next) {
var reqId = this.request.get(header) || uuid.v4();

this[ctxProp] = reqId;
Expand Down Expand Up @@ -123,7 +123,7 @@ module.exports.requestLogger = function (opts) {
this.status, data[durationField]);
};

return function *(next) {
return function *requestLogger(next) {
var url = this.url;

var requestData = {
Expand Down Expand Up @@ -213,7 +213,7 @@ module.exports.timeContext = function (opts) {
var logLevel = opts.logLevel || 'trace';
var updateLogFields = opts.updateLogFields;

return function* (next) {
return function *timeContext(next) {
this._timeContextStartTimes = {};

this.time = time;
Expand Down

0 comments on commit ffc5765

Please sign in to comment.