{"name":"diagnostics","version":"2.0.0-alpha","description":"Tools for debugging your node.js modules and event loop","main":"./node","browser":"./browser","react-native":"./react-native","scripts":{"test:basic":"mocha --require test/mock.js test/*.test.js","test:node":"mocha --require test/mock test/node.js","test:browser":"mocha --require test/mock test/browser.js","test:react-native":"mocha --require test/mock test/react-native.js","test:runner":"npm run test:basic && npm run test:node && npm run test:browser && npm run test:react-native","webpack:node:prod":"webpack --mode=production node/index.js -o /dev/null --json | webpack-bundle-size-analyzer","webpack:node:dev":"webpack --mode=development node/index.js -o /dev/null --json | webpack-bundle-size-analyzer","webpack:browser:prod":"webpack --mode=production browser/index.js -o /dev/null --json | webpack-bundle-size-analyzer","webpack:browser:dev":"webpack --mode=development browser/index.js -o /dev/null --json | webpack-bundle-size-analyzer","webpack:react-native:prod":"webpack --mode=production react-native/index.js -o /dev/null --json | webpack-bundle-size-analyzer","webpack:react-native:dev":"webpack --mode=development react-native/index.js -o /dev/null --json | webpack-bundle-size-analyzer","test":"nyc --reporter=text --reporter=lcov npm run test:runner"},"repository":{"type":"git","url":"git://github.com/3rd-Eden/diagnostics.git"},"keywords":["debug","debugger","debugging","diagnostic","diagnostics","event","loop","metrics","stats"],"author":{"name":"Arnout Kazemier"},"license":"MIT","bugs":{"url":"https://github.com/3rd-Eden/diagnostics/issues"},"homepage":"https://github.com/3rd-Eden/diagnostics","devDependencies":{"assume":"2.1.x","asyncstorageapi":"^1.0.2","mocha":"5.2.x","nyc":"^13.3.0","objstorage":"^1.0.0","pre-commit":"1.2.x","react-native":"^0.58.5","require-poisoning":"^2.0.0","webpack":"^4.29.5","webpack-bundle-size-analyzer":"^3.0.0","webpack-cli":"^3.2.3"},"dependencies":{"colorspace":"1.1.x","enabled":"^2.0.0","kuler":"1.0.x","storage-engine":"^2.0.1"},"contributors":[{"name":"Martijn Swaagman","url":"https://github.com/swaagie"},{"name":"Jarrett Cruger","url":"https://github.com/jcrugzz"},{"name":"Sevastos","url":"https://github.com/sevastos"}],"readme":"# `diagnostics`\n\nDiagnostics is an extremely small but powerful debug logger modeled after the\nNode.js core debugging technique.\n\n- Allows debugging in multiple JavaScript environments such as Node.js, browsers\n  and React-Native.\n- Separated development and production builds to minimize impact on your\n  application when bundled.\n- Allows for customization of logger, messages, and much more.\n\n## Installation\n\nThe module is released in the public npm registry and can be installed by\nrunning:\n\n```\nnpm install --save diagnostics\n```\n\n## Usage\n\n- [Introduction](#introduction)\n  - [.enabled](#enabled)\n  - [.namespace](#namespace)\n  - [.dev/prod](#dev-prod)\n- [Adapters](#adapters)\n  - [process.env](#process-env)\n  - [hash](#hash)\n  - [localStorage](#localstorage)\n  - [AsyncStorage](#asyncstorage)\n- [Modifiers](#modifiers)\n  - [namespace](#namespace)\n- [Logger](#logger)\n\n### Introduction\n\nTo create a new logger simply `require` the `diagnostics` module and call\nthe returned function the namespace under which the logs should be enabled.\nGenerally you use the name of the module or application that your developing\nas first (root) namespace.\n\n```js\nconst debug = require('diagnostics')('foo:bar:baz');\nconst debug = require('diagnostics')('foo:bar:baz', { options });\n\ndebug('this is a log message %s', 'that will only show up when enabled');\ndebug('that is pretty neat', { log: 'more', data: 1337 });\n```\n\nPlease note that the returned logger is fully configured out of the box, you\ndo not need to use any of the adapters/modifiers your self, they are there\nfor when you want more advanced control over the process.\n\nThe returned logger exposes some addition properties that can be used used in\nyour application or library.\n\n### enabled\n\nThe returned logger will have a `.enabled` property assigned to it. This boolean\ncan be used to check if the logger was enabled:\n\n```js\nconst debug = require('diagnostics')('foo:bar');\n\nif (debug.enabled) {\n  //\n  // Do something special\n  //\n}\n```\n\n### namespace\n\nThis is the namespace that you originally provided to the function.\n\n```js\nconst debug = require('diagnostics')('foo:bar');\n\nconsole.log(debug.namespace); // foo:bar\n```\n\n### dev/prod\n\nThere are different builds available of `diagnostics`, when you create a\nproduction build of your application using `NODE_ENV=production` you will be\ngiven an optimized, smaller build of `diagnostics` to reduce your bundle size.\nThe `dev` and `prod` booleans on the returned logger indicate if you have a\nproduction or development version of the logger.\n\n```js\nconst debug = require('diagnostics')('foo:bar');\n\nif (debug.prod) {\n  // do stuff\n}\n```\n\n### Modifiers\n\nModifiers allows you to programmatically alter the messages that are being\nlogged. Modifiers are applied to **all** diagnostic instances. To add a new\nmodifier you call the `modify` method of one the returned loggers. It receives\nthe following arguments:\n\n1. `message`, Array, the log message.\n2. `options`, Object, the options that were passed into the logger when it was\n   initially created.\n\n```js\nconst debug = require('diagnostics')('example:modifiers');\n\ndebug.modify(function (message, options) {\n  return messages;\n});\n```\n\nThe modifiers are only enabled for `development`.\n\n#### namespace\n\nThis modifier is enabled for all debug instances and prefixes the messages\nwith the name of namespace under which it is logged. The namespace is colored\nusing the `colorspace` module which groups similar namespaces under the same\ncolorspace. You can have multiple namespaces for the debuggers where each\nnamespace should be separated by a `:`\n\n```\nfoo\nfoo:bar\nfoo:bar:baz\n```\n\nFor console based output the `namespace-ansi` is used.\n\n### Loggers\n\nBy default it will log all messages to `console.log` in when the logger is\nenabled using the debug flag that is set using one of the adapters.\n\nYou can override the default logger by assigning your own using the `set`\nmethod. This method accepts a function as first argument which will be called\nevery time a message needs to be logged.\n\n```js\nconst debug = require('diagnostics')('foo:more:namespaces');\n\ndebug.use(function logger(meta, args) {\n  console.log(meta);\n  console.debug(...args);\n});\n```\n\nThe assigned logger will receive 2 arguments:\n\n1. `meta` An object with all the options that was provided to the original\n   logger that wants to write the log message as well as properties of the\n   debugger such as `prod`, `dev`, `namespace`, `enabled`.\n2. `args` An array of the log messages that needs to be written.\n\n### Adapters\n\nAdapters allows `diagnostics` to pull the `DEBUG` and `DIAGNOSTICS` environment\nvariables from different sources. Not every JavaScript environment has a\n`process.env` that we can leverage. Adapters allows us to have different\nadapters for different environments. It means you can write your own custom\nadapter if needed as well.\n\nThe `adapter` function should be passed a function as argument, this function\nwill receive the `namespace` of a logger as argument and it should return a\nboolean that indicates if that logger should be enabled or not.\n\n```js\nconst debug = require('diagnostics')('example:namespace');\n\ndebug.adapter(require('diagnostics/adapters/localstorage'));\n```\n\nThe modifiers are only enabled for `development`. The following adapters are\navailable are available:\n\n#### process.env\n\nThis adapter is enabled for `node.js`.\n\nUses the `DEBUG` or `DIAGNOSTICS` (both are recognized) environment variables to\npass in debug flag:\n\n**UNIX/Linux/Mac**\n```\nDEBUG=foo* node index.js\n```\n\nUsing environment variables on Windows is a bit different, and also depends on\ntoolchain you are using:\n\n**Windows**\n```\nset DEBUG=foo* & node index.js\n```\n\n**Powershell**\n```\n$env:DEBUG='foo*';node index.js\n```\n\n#### hash\n\nThis adapter is enabled for `browsers`.\n\nThis adapter uses the `window.location.hash` of as source for the environment\nvariables. It assumes that hash is formatted using the same syntax as query\nstrings:\n\n```\nhttp://example.com/foo/bar#debug=foo*\n```\n\nIt triggers on both the `debug=` and `diagnostics=` names.\n\n#### localStorage\n\nThis adapter is enabled for `browsers`.\n\n## License\n\nMIT\n","readmeFilename":"README.md","gitHead":"ad8961245231a992f8f9de5ed18d19a7789fe0b1","_id":"diagnostics@2.0.0-alpha","_npmVersion":"6.4.0","_nodeVersion":"8.11.4","_npmUser":{"name":"3rdeden","email":"npm@3rd-Eden.com"},"dist":{"integrity":"sha512-07YThBSC6MQnZYoHJ3knI13bfXXCkrpMQ/qrr+6E8ziRJiMZK4/8evAct/LHk5XQ5vuDPEyOgT2fRPai1cwoYA==","shasum":"b32f1c8519692ea8945aa2142ff37b02134c28cb","tarball":"http://registry-npm.ywwl.com/diagnostics/download/diagnostics-2.0.0-alpha.tgz","fileCount":25,"unpackedSize":25668,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcbsQZCRA9TVsSAnZWagAANKwP/3b8zwokgB2bbdp4ZByL\n1FS+ujwNrDHgSSBPCXCGx3sx+jzQ0RXiw5TMImWLkJk5psIWam3zCEybiwkU\nyvQs5Q+mVTjcZB9ST0ZydiAQjPfJceDyq6QhBKPkP1jWzlj4dEjje7Udm9RQ\nlM4JRIsummWYdMQJEcHBVyjtIPWisWZN1RttG/cL9YN364z2rL9oiotPdikX\ngqEiTaWPocTXdQCKdvJAnJlG8N8GMcSX1KqhvSG6EQ5buAQCQwTAhqbH8zqm\nj5ve/rAdCLzlYGg9ib7CN+hXMvI+YlWQf8ZqX2x5XQoONRHU1jLOAv89Ggs8\nx0/7Z1V7/lrNP5+FfC6RndpY3A5vmvTuCsbgPXu5O4Z8tpDPLI3WizwXRmp2\n1+vDmd/IFRdHKPx/f6otcTOYXB/xuw2hpF5vSaTklJTbmCEu+BUB/H48PPa3\nFdAsLrDaw2ODHnfZqvoIk/SC8MRM+fY1lxrpoXhhUOHC3QD7L7WhNhTqiHaz\nYqwQf8n53yAv1t3n/idaRyKXVNzQXHf6WwoT2+34PqldDZNoIgb8QN4y3JW/\nkhONJW0344L6STqmQ5iguVoLuhVh51keLhmXhiiHEnBS3mCsfiuCB3yV2DR3\nHd3/VVN9x1B72KxqEWNm0pKRSxE13ImMPcU0tUAN27snjnJSkpnC8S4+RjhB\nNL3w\r\n=sBAw\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDMFRYR8MtokxL9RLvpK8aDL1/iePvWd/n3Ollw07Su6AIhAPlt70w5xGm3J6dkKP/xLki9/cQ4sN/Cp2We0IkbzYDh"}],"size":8274,"noattachment":false,"key":"/diagnostics/-/diagnostics-2.0.0-alpha.tgz"},"maintainers":[{"email":"npm@3rd-Eden.com","name":"3rdeden"},{"email":"info@martijnswaagman.nl","name":"swaagie"},{"email":"npm@3rd-Eden.com","name":"v1"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/diagnostics_2.0.0-alpha_1550763032378_0.7134256100458873"},"_hasShrinkwrap":false,"publish_time":1550763032570,"_cnpm_publish_time":1550763032570,"dist-tags":{"latest":"3.0.0","next":"2.0.0-alpha"}}