{"_id":"ctx-logger","_rev":"7-24bc36e6595e8606eec309d6a0ff0a52","name":"ctx-logger","description":"logger with multiple stores and auto context support","dist-tags":{"latest":"2.0.1"},"versions":{"0.1.0":{"name":"ctx-logger","description":"logger with multiple stores and auto context support","version":"0.1.0","homepage":"https://github.com/kiliwalk/ctx-logger","bugs":{"url":"https://github.com/kiliwalk/ctx-logger/issues"},"license":"MIT","main":"index.js","preferGlobal":false,"author":{"name":"kiliwalk","email":"kiliwalk@qq.com"},"repository":{"type":"git","url":"git+https://github.com/kiliwalk/ctx-logger.git"},"keywords":["logger","context","auto context","request context","mutiple stores","console logger","file logger","profile","profiling"],"dependencies":{"colors":"^1.1.2"},"devDependencies":{"mocha":"^2.3.2","sandboxed-module":"^2.0.3"},"subdomain":"kiliwalk.org","engines":{},"scripts":{"test":"mocha -b --reporter spec","test-cov":"istanbul cover node_modules/mocha/bin/_mocha -- --reporter spec"},"gitHead":"3f65282d1654d6f59884e2abc4e4ce02c9e4ff96","_id":"ctx-logger@0.1.0","_shasum":"7c2968b4c1884115de47d72a9f1700165e93f5fe","_from":".","_npmVersion":"2.13.5","_nodeVersion":"0.10.40","_npmUser":{"name":"kiliwalk","email":"kiliwalk@qq.com"},"dist":{"shasum":"7c2968b4c1884115de47d72a9f1700165e93f5fe","tarball":"https://registry.npmjs.org/ctx-logger/-/ctx-logger-0.1.0.tgz","integrity":"sha512-gaFjarOba8uYWPe0nbfjyUM9PJL5j5uvD+fDgH6CGb88mHMu6c/FTXzvhAX4iGaZP2hrHzgG0ryTOcGljj0O9A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBj8CPRoKGSmymW59KfkOFur3B72zo6v4GCIhK2pmiyaAiEApclmvjuDNt4RjXNk37nKRdfPvyLoaym+260KhVRK63Q="}]},"maintainers":[{"name":"kiliwalk","email":"kiliwalk@qq.com"}]},"1.0.0":{"name":"ctx-logger","description":"logger with multiple stores and auto context support","version":"1.0.0","homepage":"https://github.com/kiliwalk/ctx-logger","bugs":{"url":"https://github.com/kiliwalk/ctx-logger/issues"},"license":"MIT","main":"index.js","preferGlobal":false,"author":{"name":"kiliwalk","email":"kiliwalk@qq.com"},"repository":{"type":"git","url":"git+https://github.com/kiliwalk/ctx-logger.git"},"keywords":["logger","context","auto context","request context","mutiple stores","console logger","file logger","profile","profiling"],"dependencies":{"colors":"^1.1.2"},"devDependencies":{"mocha":"^2.3.2","sandboxed-module":"^2.0.3"},"subdomain":"kiliwalk.org","engines":{},"scripts":{"test":"mocha -b --reporter spec","test-cov":"istanbul cover node_modules/mocha/bin/_mocha -- --reporter spec"},"gitHead":"3660a0c264f4e0b5e4ad6b7644bd813dd1a05563","_id":"ctx-logger@1.0.0","_shasum":"8c2537312d596e9ec5bee381a783ee62fb2e4bd7","_from":".","_npmVersion":"2.13.5","_nodeVersion":"0.10.40","_npmUser":{"name":"kiliwalk","email":"kiliwalk@qq.com"},"dist":{"shasum":"8c2537312d596e9ec5bee381a783ee62fb2e4bd7","tarball":"https://registry.npmjs.org/ctx-logger/-/ctx-logger-1.0.0.tgz","integrity":"sha512-xKhhj0IbRGtyCyk2wdFiDhPSiNHCbn4vezvc33RU3yDdlcO2Mn/TCYOJ5DzNlAzHO6pwj/zvMAXn43ixaXJJdw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD/qgcws0FIDazlk3Qhyp9ghf2hpWzOPRJoLgm0iYYEqwIgD//q8yNe9dwBkUZt1ZfkRkn326aw2MzacVHIK69DltU="}]},"maintainers":[{"name":"kiliwalk","email":"kiliwalk@qq.com"}]},"1.0.1":{"name":"ctx-logger","description":"logger with multiple stores and auto context support","version":"1.0.1","homepage":"https://github.com/kiliwalk/ctx-logger","bugs":{"url":"https://github.com/kiliwalk/ctx-logger/issues"},"license":"MIT","main":"index.js","preferGlobal":false,"author":{"name":"kiliwalk","email":"kiliwalk@qq.com"},"repository":{"type":"git","url":"git+https://github.com/kiliwalk/ctx-logger.git"},"keywords":["logger","context","context-logger","auto context","request context","mutiple stores","console logger","file logger","profile","profiling"],"dependencies":{"colors":"^1.1.2"},"devDependencies":{"mocha":"^2.3.2","sandboxed-module":"^2.0.3"},"subdomain":"kiliwalk.org","engines":{},"scripts":{"test":"mocha -b --reporter spec","test-cov":"istanbul cover node_modules/mocha/bin/_mocha -- --reporter spec"},"gitHead":"3660a0c264f4e0b5e4ad6b7644bd813dd1a05563","_id":"ctx-logger@1.0.1","_shasum":"90e886410c3cbbdd4922798dc9190b44bf4a97dc","_from":".","_npmVersion":"2.13.5","_nodeVersion":"0.10.40","_npmUser":{"name":"kiliwalk","email":"kiliwalk@qq.com"},"dist":{"shasum":"90e886410c3cbbdd4922798dc9190b44bf4a97dc","tarball":"https://registry.npmjs.org/ctx-logger/-/ctx-logger-1.0.1.tgz","integrity":"sha512-LuwOezGCkVkXurFxeLhsqzTuCcKeCyqWTO8cW+L9TQOZdrmtj6O/rSCOviwybTnNrOlEwoUzBuAx9TivR6xFkA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHg0wJ6j0HVvnkEQC5tN3eFzDSTd+Sm9Kq9yla7pUHfSAiEAoz01zZ1P7+3GJGhcRn4M0h1WN89Ut8xBpBj1JyZ1LWI="}]},"maintainers":[{"name":"kiliwalk","email":"kiliwalk@qq.com"}]},"2.0.0":{"name":"ctx-logger","description":"logger with multiple stores and auto context support","version":"2.0.0","homepage":"https://github.com/kiliwalk/ctx-logger","bugs":{"url":"https://github.com/kiliwalk/ctx-logger/issues"},"license":"MIT","main":"index.js","preferGlobal":false,"author":{"name":"kiliwalk","email":"kiliwalk@qq.com"},"repository":{"type":"git","url":"git+https://github.com/kiliwalk/ctx-logger.git"},"keywords":["logger","context","context-logger","auto context","request context","mutiple stores","console logger","file logger","profile","profiling","flush on exit"],"dependencies":{"colors":"^1.1.2"},"devDependencies":{"mocha":"^2.3.2","sandboxed-module":"^2.0.3"},"subdomain":"kiliwalk.org","engines":{},"scripts":{"test":"mocha -b --reporter spec","test-cov":"istanbul cover node_modules/mocha/bin/_mocha -- --reporter spec"},"gitHead":"29ba85aff9001dbdaa7bff75da863f5c00e3aebc","_id":"ctx-logger@2.0.0","_shasum":"801c93b6febbb4e949f12984032831663a593d6f","_from":".","_npmVersion":"2.13.5","_nodeVersion":"0.10.40","_npmUser":{"name":"kiliwalk","email":"kiliwalk@qq.com"},"dist":{"shasum":"801c93b6febbb4e949f12984032831663a593d6f","tarball":"https://registry.npmjs.org/ctx-logger/-/ctx-logger-2.0.0.tgz","integrity":"sha512-TLvWtSrfHb5NZ82g3FXz6xutG47mNS0xFIy/IZesK5SPk4nk/sNTvgx0hhYEWajrhXzWorhRpPO0l1ok+U1tHg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFJIPcpDRgcRkSP7vT4T359WDoy0a9w4ZdwrEyO4VMIzAiAc6Cb6Kz86BfJu72ObhaVt7p1/0p8cy1Uw2uLMdnGcDQ=="}]},"maintainers":[{"name":"kiliwalk","email":"kiliwalk@qq.com"}]},"2.0.1":{"name":"ctx-logger","description":"logger with multiple stores and auto context support","version":"2.0.1","homepage":"https://github.com/kiliwalk/ctx-logger","bugs":{"url":"https://github.com/kiliwalk/ctx-logger/issues"},"license":"MIT","main":"index.js","preferGlobal":false,"author":{"name":"kiliwalk","email":"kiliwalk@qq.com"},"repository":{"type":"git","url":"git+https://github.com/kiliwalk/ctx-logger.git"},"keywords":["logger","context","context-logger","auto context","request context","mutiple stores","console logger","file logger","profile","profiling","flush on exit"],"dependencies":{"colors":"^1.1.2"},"devDependencies":{"mocha":"^2.3.2","sandboxed-module":"^2.0.3"},"subdomain":"kiliwalk.org","engines":{},"scripts":{"test":"mocha -b --reporter spec","test-cov":"istanbul cover node_modules/mocha/bin/_mocha -- --reporter spec"},"gitHead":"897e69f2a0112a055053512c44e77acc28691081","_id":"ctx-logger@2.0.1","_shasum":"5be08f78d4e78fa6ad11709f888a7395a560493c","_from":".","_npmVersion":"2.13.5","_nodeVersion":"0.10.40","_npmUser":{"name":"kiliwalk","email":"kiliwalk@qq.com"},"dist":{"shasum":"5be08f78d4e78fa6ad11709f888a7395a560493c","tarball":"https://registry.npmjs.org/ctx-logger/-/ctx-logger-2.0.1.tgz","integrity":"sha512-vLBpKWFGJjDjPoOFyMIJqpcEsh/8BRiXiNg0/lP1uOwTDcaY0+ppDCWY9rJTzSum0j9Tje5KRYodyX97UEsG/g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD7fQV2UqX1nK80HShpeKTjAjaxrvWP5ryLT6vMB7qY9gIgRTYfolw/BcHcFW3CAMv8wknMRzzJDJsRNNePMzgSIGw="}]},"maintainers":[{"name":"kiliwalk","email":"kiliwalk@qq.com"}]}},"readme":"logger with multiple stores and auto context support\r\n=================================\r\n\r\n### Features\r\n\r\n* normal debug/info/warn/error operation\r\n* support time/timeEnd for profiling\r\n* multiple stores(console/file/db...)\r\n* **auto flush on process exit(SIGINT)**\r\n* **log the context(through the web request...)**\r\n\r\n\r\n### Usage\r\n\r\nwhen you create a new logger object, you can set the following options:\r\n\r\n* `stores`: store's map object. the key is the store instance's name. Each store has the common options:\r\n    * `class`: the store class, which can be the package name string, or the require return\r\n    * `level`: the threshold level(`DEBUG/INFO/WARN/ERROR/OFF`). default is `DEBUG`\r\n    * `time`: whether to record time/timeEnd operation. default is `true`\r\n* `context`: the context variable names. these variables are attached in the `process.domain`\r\n\r\nif you do not set the `stores` option, a internal `ConsoleStore` will be used. it can also be retreived by `require('ctx-logger').ConsoleStore`.\r\n\r\n```js\r\nvar Logger = require('ctx-logger');\r\n\r\n//use the internal ConsoleStore\r\nvar logger = new Logger();\r\n...\r\n\r\n//create a logger with a console store and a file store\r\nvar logger = new Logger({stores: {\r\n  console: {class: Logger.ConsoleStore},\r\n  file: {class: 'ctx-logger-file-store', dir: './log'}\r\n}});\r\n...\r\n\r\nlogger.time('label a');\r\nlogger.debug('a debug message');\r\nlogger.info('a info message');\r\nlogger.warn('a warn message');\r\nlogger.error('a error message');\r\nlogger.timeEnd('label a');\r\n\r\n```\r\n\r\n### Used with context\r\n\r\nIn web http request, you may want to distinguish the differenct log messages produced by differenct users with the only one logger. Here, you can! see the code(with `express`):\r\n\r\n```js\r\n//add the domain middleware\r\napp.use(function(req, resp, next){\r\n  var reqDomain = require('domain').create();\r\n  reqDomain.on('error', function (err) {\r\n    /*error handler*/\r\n  });\r\n\r\n  //set the context var to the user id, assume it's kiliwalk\r\n  reqDomain.userId = req.session.userId;\r\n  \r\n  reqDomain.add(req);\r\n  reqDomain.add(resp);\r\n  reqDomain.run(next);\r\n});\r\n\r\n\r\nvar logger = new Logger({stores: {\r\n  console: {class: Logger.ConsoleStore},\r\n}, context: 'userId'});\r\n\r\napp.get('/test', function(req, resp){\r\n  logger.debug('visit test page');\r\n});\r\n\r\n```\r\n\r\nthe output will be:\r\n```\r\n2015-09-15 11:11:11 DEBUG [kiliwalk] visit test page\r\n```\r\n\r\n### Stores\r\n\r\n* [internal console store](#Internal console store)\r\n* [ctx-logger-file-store](https://www.npmjs.com/package/ctx-logger-file-store)\r\n\r\n\r\n### Internal console store\r\n\r\nyou can choose whether enable colored output in console. just set the `color` option. default is `true`.\r\n```js\r\nvar logger = new Logger({stores: {\r\n  console: {class: Logger.ConsoleStore, color: false},\r\n}});\r\n```\r\n\r\n### License :\r\n\r\nLicensed under MIT\r\n\r\nCopyright (c) 2015 [kiliwalk](https://github.com/kiliwalk)\r\n","maintainers":[{"name":"kiliwalk","email":"kiliwalk@qq.com"}],"time":{"modified":"2022-06-14T05:35:07.248Z","created":"2015-09-16T14:55:01.593Z","0.1.0":"2015-09-16T14:55:01.593Z","1.0.0":"2015-09-16T15:08:34.985Z","1.0.1":"2015-09-16T15:51:00.198Z","2.0.0":"2015-09-26T15:43:55.761Z","2.0.1":"2015-10-19T04:54:16.925Z"},"homepage":"https://github.com/kiliwalk/ctx-logger","keywords":["logger","context","context-logger","auto context","request context","mutiple stores","console logger","file logger","profile","profiling","flush on exit"],"repository":{"type":"git","url":"git+https://github.com/kiliwalk/ctx-logger.git"},"author":{"name":"kiliwalk","email":"kiliwalk@qq.com"},"bugs":{"url":"https://github.com/kiliwalk/ctx-logger/issues"},"license":"MIT","readmeFilename":"README.md"}