{"name":"zlogger","version":"0.0.0","_id":"zlogger@0.0.0","scripts":{},"_shasum":"43ae510951e12c9eae92133f22412c4dcba8ab6c","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.9.1","_npmUser":{"name":"popomore","email":"sakura9515@gmail.com"},"dist":{"shasum":"43ae510951e12c9eae92133f22412c4dcba8ab6c","tarball":"http://registry-npm.ywwl.com/zlogger/download/zlogger-0.0.0.tgz","integrity":"sha512-oCG9HMFkmZmfmTRJHxag7h9bBt6/IvYa0/CZyTbiRjh8DX4Y8yClh2X+zs5SEmcicnDserupfpulkBRNDaVuFw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIA8DbyugUtWO/V0Lq6NLeCnOdM1x/4kT2h4meACfesrKAiAK9XoCL7os4B+xCScwz4VOQF6/ucO1ZVbf4FjQ2URgVg=="}],"size":152,"noattachment":false,"key":"/zlogger/-/zlogger-0.0.0.tgz"},"maintainers":[{"name":"popomore","email":"sakura9515@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/zlogger-0.0.0.tgz_1480097963727_0.9148246904369444"},"directories":{},"readme":"# zlogger\n\n[![NPM version][npm-image]][npm-url]\n[![build status][travis-image]][travis-url]\n[![Test coverage][codecov-image]][codecov-url]\n[![David deps][david-image]][david-url]\n[![Known Vulnerabilities][snyk-image]][snyk-url]\n[![npm download][download-image]][download-url]\n\n[npm-image]: https://img.shields.io/npm/v/zlogger.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/zlogger\n[travis-image]: https://img.shields.io/travis/node-modules/zlogger.svg?style=flat-square\n[travis-url]: https://travis-ci.org/node-modules/zlogger\n[codecov-image]: https://codecov.io/gh/node-modules/zlogger/branch/master/graph/badge.svg\n[codecov-url]: https://codecov.io/gh/node-modules/zlogger\n[david-image]: https://img.shields.io/david/node-modules/zlogger.svg?style=flat-square\n[david-url]: https://david-dm.org/node-modules/zlogger\n[snyk-image]: https://snyk.io/test/npm/zlogger/badge.svg?style=flat-square\n[snyk-url]: https://snyk.io/test/npm/zlogger\n[download-image]: https://img.shields.io/npm/dm/zlogger.svg?style=flat-square\n[download-url]: https://npmjs.org/package/zlogger\n\nThe last console logger\n\n## Installation\n\n```bash\nnpm install --save zlogger\n```\n\n## Feature\n\n- ✔︎ Extends [Console](https://nodejs.org/api/console.html#console_new_console_stdout_stderr)\n- ✔︎ Support custom prefix before every line\n- ✔︎ Support custom stdout and stderr\n- ✔︎ Support print time\n- ✔︎ Support child logger\n- ✔︎ Support logger level\n\n## Usage\n\nzlogger is same as global `console` which has `.log`, `.info`, `.warn`, `.error`.\n\nEvery line will start with `prefix` that you customize.\n\n```js\nconst logger = new ConsoleLogger({\n  prefix: '> ',\n});\n```\n\nSupport log level: `DEBUG` / `INFO` / `WARN` / `ERROR`.\n\n```js\nconst logger = new ConsoleLogger({\n  prefix: '> ',\n  level: 'WARN',\n});\n\nlogger.error('msg_error');\nlogger.info('msg_info');\n\n// [15:03:46] prefix > msg_error\n```\n\nSpecify stdout/stderr, default is `process.stdout/process.stderr`, you can use `fs` if you want to print to file.\n\n```js\nconst logger = new ConsoleLogger({\n  stdout: fs.createWriteStream('stdout.log'),\n  stderr: fs.createWriteStream('stderr.log'),\n});\nlogger.info('info');\nlogger.error('error');\n\n// cat stdout.log\n// cat stderr.log\n```\n\nYou can create a child logger, the first argument can be a ChildProcess or writable stream. If you give a prefix, it will print after prefix defined by the parent logger.\n\n```js\nconst cp = require('child_process');\nconst logger = new ConsoleLogger({\n  prefix: 'prefix > ',\n});\nlogger.info('see directory')\n\nconst ls = cp.spawn('ls', { cwd: __dirname });\nlogger.child(ls, '> ');\n\n// [15:03:46] prefix > see directory\n// [15:03:46] prefix > > History.md\n// [15:03:46] prefix > > README.md\n// [15:03:46] prefix > > index.js\n// [15:03:46] prefix > > node_modules\n// [15:03:46] prefix > > package.json\n// [15:03:46] prefix > > test\n```\n\n`.child` will return a new logger.\n\n```js\nconst logger = new ConsoleLogger({\n  prefix: 'parent> ',\n});\nlogger.info('parent');\n\nconst child = logger.child('child> ');\nchild.info('child');\n\n// [15:02:43] parent> parent\n// [15:02:43] parent> child> child\n```\n\nIt will print time before prefix, format is `[HH:MM:SS] `, but you can disable it.\n\n## Options\n\n- {WriteStream} stdout - stdout, `.log` and `.info` will pipe to it，default is process.stdout\n- {WriteStream} stderr - stderr, `.warn` and `.error` will pipe to it，default is process.stderr\n- {String|Function} prefix - every line will start with `prefix`, if it's a function, it will be called every line print.\n- {Boolean} time - print time\n- {String|Number} level - log level\n\n## License\n\n(The MIT License)\n","publish_time":1480097965690,"_cnpm_publish_time":1480097965690,"dist-tags":{"latest":"2.1.1"}}