{"name":"hapi-pino","version":"2.2.0","description":"Hapi plugin for the Pino logger ","main":"index.js","scripts":{"coverage":"lab test.js -c","coveralls":"lab test.js -r lcov | coveralls","test":"standard && lab test.js"},"keywords":["hapi","pino","logger","fast","slow","json"],"license":"MIT","devDependencies":{"code":"^4.1.0","coveralls":"^2.11.15","flush-write-stream":"^1.0.0","good":"^7.0.2","good-console":"^6.3.1","hapi":"^16.4.3","lab":"^14.0.0","pre-commit":"^1.1.2","split2":"^2.0.1","standard":"^10.0.0"},"dependencies":{"abstract-logging":"^1.0.0","pino":"^4.10.2"},"repository":{"type":"git","url":"git+https://github.com/pinojs/hapi-pino.git"},"author":{"name":"David Mark Clements"},"bugs":{"url":"https://github.com/pinojs/hapi-pino/issues"},"homepage":"https://github.com/pinojs/hapi-pino#readme","readme":"# hapi-pino&nbsp;&nbsp;[![Build Status](https://travis-ci.org/pinojs/hapi-pino.svg)](https://travis-ci.org/pinojs/hapi-pino) [![Coverage Status](https://coveralls.io/repos/github/pinojs/hapi-pino/badge.svg?branch=master)](https://coveralls.io/github/pinojs/hapi-pino?branch=master)\n\n\n[Hapi](http://hapijs.com) plugin for the [Pino](https://github.com/pinojs/pino) logger. It logs in JSON for easy\npost-processing.\nIt is faster than [good](http://npm.im/good) console logger by a 20%\nfactor, which increases to 30% when using [extreme\nmode](https://github.com/pinojs/pino#extreme). Using hapi-pino in\nextreme mode allows the \"hello world\" example to handle 30% more\nthroughput than good.\n\n__hapi-pino__ v2.x.x supports Hapi v16.\n\n## Install\n\n```\nnpm i hapi-pino@2 --save\n```\n\n## Usage\n\n```js\n'use strict'\n\nconst Hapi = require('hapi')\n\n// Create a server with a host and port\nconst server = new Hapi.Server()\nserver.connection({\n  host: 'localhost',\n  port: 3000\n})\n\n// Add the route\nserver.route({\n  method: 'GET',\n  path: '/',\n  handler: function (request, reply) {\n    // request.log is HAPI standard way of logging\n    request.log(['a', 'b'], 'Request into hello world')\n\n    // you can also use a pino instance, which will be faster\n    request.logger.info('In handler %s', request.path)\n\n    return reply('hello world')\n  }\n})\n\nserver.register(require('hapi-pino'), (err) => {\n  if (err) {\n    console.error(err)\n    process.exit(1)\n  }\n\n  // The logger is available as a decorated API\n  server.logger().info('another way for accessing it')\n\n  // and through Hapi standard logging system\n  server.log(['subsystem'], 'third way for accessing it')\n\n  // Start the server\n  server.start((err) => {\n    if (err) {\n      console.error(err)\n      process.exit(1)\n    }\n  })\n})\n```\n\n## API\n\n- [Options](#options)\n- [Server decorations](#serverdecorations)\n- [Request decorations](#requestdecorations)\n- [Hapi Events](#hapievents)\n\n**hapi-pino** goal is to enable Hapi applications to log via [pino][pino]. To enable this, it decorates both the [server](#serverdecorations) and the [request](#requestadditions). Moreover, **hapi-pino**\n binds to the Hapi events system as described in the [\"Hapi\nevents\"](#hapievents) section.\n\n### Options\n- `[logPayload]` – when enabled, add the request payload as `payload` to the `response` event log. Defaults to `false`.\n- `[stream]` - the binary stream to write stuff to, defaults to\n  `process.stdout`.\n- `[prettyPrint]` - pretty print the logs (same as `node server |\n  pino`), disable in production. Default is `false`, enable in\n  development by passing `true`.\n- `[tags]` - a map to specify pairs of Hapi log tags and levels. By default,\n  the tags *trace*, *debug*, *info*, *warn*, and *error* map to their\n  corresponding level. Any mappings you supply take precedence over the default\n  mappings. The default level tags are exposed via `hapi-pino.levelTags`.\n- `[allTags]` - the logging level to apply to all tags not matched by\n  `tags`, defaults to `'info'`.\n- `[instance]` - uses a previously created Pino instance as the logger.\n  The instance's `stream` and `serializers` take precedence.\n- `[logEvents]` - Takes an array of strings with the events to log. Default is to\n  log all events e.g. `['onPostStart', 'onPostStop', 'response', 'request-error']`.\n  Set to `false/null` to disable all events.\n- `[mergeHapiLogData]` - When enabled, Hapi-pino will merge the data received\n  from Hapi's logging interface (`server.log(tags, data)` or `request.log(tags, data)`)\n  into Pino's logged attributes at root level. If data is a string, it will be used as\n  the value for the `msg` key. Default is `false`, in which case data will be logged under \n  a `data` key.\n\n  E.g.\n```js\nserver.log(['info'], {hello: 'world'})\n\n// with mergeHapiLogData: true\n{ level: 30, hello: 'world', ...}\n\n// with mergeHapiLogData: false (Default)\n{ level: 30, data: { hello: 'world' }}\n```\n\n<a name=\"serverdecorations\"></a>\n### Server Decorations\n\n**hapi-pino** decorates the Hapi server with:\n\n* `server.logger()`, which is a function that returns the current instance of\n  [pino][pino], see its doc for the way to actual log.\n* `server.app.logger`, same as before, but the logger it is also\n  attached to the `server.app` object.\n\n<a name=\"requestdecorations\"></a>\n### Request Decorations\n\n**hapi-pino** decorates the Hapi request with:\n\n* `request.logger`, which is an instance of [pino][pino] bound to the current request, so you can trace all the logs of a given request. See [pino][pino] doc for the way to actual log.\n\n<a name=\"hapievents\"></a>\n### Hapi Events\n\n**hapi-pino** listens to some Hapi events:\n\n* `'onRequest'`, to create a request-specific child logger\n* `'response'`, to log at `'info'` level when a request is completed\n* `'response-error'`, to log at `'warn'` level when a request errors\n* `'log'`, to support logging via the Hapi `server.log()` and\n  `request.log()` methods, see `tags` and `allTags` options.\n* `'onPostStart'`, to log when the server is started\n* `'onPostStop'`, to log when the server is stopped\n\n## Acknowledgements\n\nThis project was kindly sponsored by [nearForm](http://nearform.com).\n\n## License\n\nMIT\n\n[pino]: https://github.com/pinojs/pino\n","readmeFilename":"README.md","gitHead":"f8689042f7fd01fef2899d0cc591d7207d3a39b1","_id":"hapi-pino@2.2.0","_npmVersion":"5.6.0","_nodeVersion":"8.9.4","_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"dist":{"integrity":"sha512-YABJJnuENhwV/BHgpLPLifuhHBZZ8+feg+9luoj3OLUDPOuW/zajgr7IN8F9AWP3a2mPEpa+y/SPakqqw0uTLw==","shasum":"f314d146712499a60a4bc1e1a39ede0a89cd0a62","tarball":"http://registry-npm.ywwl.com/hapi-pino/download/hapi-pino-2.2.0.tgz","fileCount":14,"unpackedSize":34107,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAVbR0gsrFpfw8dov+EQBhas9Yc0b8YnviYpe2SH10gmAiEAkM4SLI2f+mCLAjPMMRbe5okY7Tju6n9Gr/dD92BYI+w="}],"size":7481,"noattachment":false,"key":"/hapi-pino/-/hapi-pino-2.2.0.tgz"},"maintainers":[{"email":"huperekchuno@googlemail.com","name":"davidmarkclements"},{"email":"james.sumners@gmail.com","name":"jsumners"},{"email":"hello@matteocollina.com","name":"matteo.collina"},{"email":"w@tson.dk","name":"watson"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hapi-pino_2.2.0_1518696853608_0.8256642129326683"},"_hasShrinkwrap":false,"publish_time":1518696854264,"_cnpm_publish_time":1518696854264,"dist-tags":{"latest":"13.0.0","version16":"2.3.0"}}