{"name":"restify-bunyan-logger","version":"2.0.6","main":"lib/index.js","bin":{"restify-bunyan-logger":"./bin/restify-bunyan-logger"},"scripts":{"lint":"jshint lib/"},"dependencies":{"underscore":"^1.7.0"},"devDependencies":{},"repository":{"type":"git","url":"https://github.com/AnyFetch/restify-bunyan-logger"},"licence":"MIT","engines":{"node":">=0.10"},"gitHead":"b3435b014e167ef737d082d9b642b0e9519ada86","description":"Bunyan Logger for Restify =========================","bugs":{"url":"https://github.com/AnyFetch/restify-bunyan-logger/issues"},"homepage":"https://github.com/AnyFetch/restify-bunyan-logger","_id":"restify-bunyan-logger@2.0.6","_shasum":"b4833b980ceebad1b5ce4ee5d44de164326bcdd6","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"matthieu.bacconnier","email":"matthieu.bacconnier@papiel.fr"},"maintainers":[{"name":"matthieu.bacconnier","email":"matthieu.bacconnier@papiel.fr"}],"dist":{"shasum":"b4833b980ceebad1b5ce4ee5d44de164326bcdd6","tarball":"http://registry-npm.ywwl.com/restify-bunyan-logger/download/restify-bunyan-logger-2.0.6.tgz","integrity":"sha512-rDe2+wyiAiS3tqU2WLy5JkRu1bS12sArXqRBHloEBgmk4lW8gqNi6KgswMQYI+5DWKph8XXDxszmhaoCzUZ4uQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD0tWD2yG083z3A1NHafOznkp72a7Km7Hj1YSflzOExuQIgfdNdTjA09t6i23AG9asWGPqPsdnZiUkdu0dle+Hd1rM="}],"size":17603,"noattachment":false,"key":"/restify-bunyan-logger/-/restify-bunyan-logger-2.0.6.tgz"},"directories":{},"readme":"Bunyan Logger for Restify\n=========================\n\nAdd bunyan logging to your restify app.\n\n## Installation\n```\nnpm install restify-bunyan-logger\n```\n\nUse `--save` to add the package to your current package.json.\n\n## Usage\nBasic usage is one line (if you're already using bunyan):\n\n```js\nvar restifyBunyanLogger = require('restify-bunyan-logger');\nserver.on('after', restifyBunyanLogger());\n```\n\nIf you're not using bunyan, you'll need to update your server creation too:\n\n```js\nvar Logger = require('bunyan');\nvar server = restify.createServer({\n  log: new Logger.createLogger({\n    name: \"your app name\",\n  })\n});\n```\n\n\n### Parameters\n`restifyBunyanLogger` takes an option parameter. Valid keys are:\n\n* `skip`: function to skip some logs. Take as parameters req and res, must return true to skip the logging of this request.\n* `custom`: function to add custom values to the bunyan log. Take as parameters req, res, route, err, log (a pre defined log object). Must return a Javascript object.\n* `logger`: a custom bunyan logger. Will default to req.log if unspecified\n\n```js\nserver.on('after', restifyBunyanLogger({\n  skip: function(req, res) {\n    return req.method === \"OPTIONS\";\n  },\n  custom: function(req, res, route, err, log) {\n    // This will not work when using gzip.\n    log.res.length = res.get('Content-Length');\n\n    // Don't forget to return!\n    return log;\n  },\n  logger: bunyanLogger\n}));\n```\n\n## CLI usage\nYou can pipe your json logs into `bin/restify-bunyan-logger` (or `restify-bunyan-logger` when installed with `npm -g`) to get a nicely formatted one-line view.\n\nThis is a dirty hack around the standard bunyan logger, until https://github.com/trentm/node-bunyan/pull/191 is merged.\n\n## More...\nThis package fits nicely with the default restify bunyan implementation, and will use any custom logger you want.\nYou may want to add `server.use(restify.requestLogger());` to get a unique request identifier on each log.\n\n## I'm using express\nI'm quite sad for you. If you want, you can use this simple wrapper to get lbunyan logging on express:\n\n```js\n'use strict';\nvar onFinished = require('on-finished');\nvar BunyanLogger = require('restify-bunyan-logger');\nvar Logger = require('bunyan');\n\n\nvar bunyanLogger = new BunyanLogger({\n  custom: function(req, res, route, err, log) {\n    log.req.route = req.route ? req.route.path : null;\n    return log;\n  },\n  logger: new Logger.createLogger(),\n});\n\n\n\nmodule.exports = function(req, res, next) {\n  req._startAt = new Date();\n  onFinished(res, function(err) {\n    req.time = function() {\n      return req._startAt;\n    };\n    bunyanLogger(req, res, null, err);\n  });\n\n  next();\n};\n```\n","publish_time":1417107331778,"_cnpm_publish_time":1417107331778,"dist-tags":{"latest":"2.0.7"}}