{"_id":"winston-log-and-exit","_rev":"8-8ccadf04c7e457fe6c3a88641f3aca19","name":"winston-log-and-exit","description":"Patch for assuring that winston log messages are written to file before exiting","dist-tags":{"latest":"1.0.6"},"versions":{"1.0.0":{"name":"winston-log-and-exit","version":"1.0.0","description":"Patch for assuring that winston log messages are written to file before exiting","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/jdthorpe/winston-log-and-exit.git"},"keywords":["winston","exit","process.exit","flush"],"author":{"name":"Jason Thorpe"},"license":"MIT","bugs":{"url":"https://github.com/jdthorpe/winston-log-and-exit/issues"},"homepage":"https://github.com/jdthorpe/winston-log-and-exit#readme","gitHead":"cf9c0f086b65b36cd7348651ce58e45bfc29d40b","_id":"winston-log-and-exit@1.0.0","_shasum":"8654ddf1c648aab376c6522408194abe6d71eb26","_from":".","_npmVersion":"3.10.9","_nodeVersion":"6.9.2","_npmUser":{"name":"jdthorpe","email":"jdthorpe@gmail.com"},"dist":{"shasum":"8654ddf1c648aab376c6522408194abe6d71eb26","tarball":"https://registry.npmjs.org/winston-log-and-exit/-/winston-log-and-exit-1.0.0.tgz","integrity":"sha512-V+1rSUMma0m3alrOXL9IiYbLVwNeK12MoMgDhrfHepEXD+Wv/KMa7qW/rhyVhw/uy6fLl59I8GRymOb2N2YZfw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEMCHxbD0E4IMB3v5jLPK2lLmcVBJ6yQiOTvUGDRMIQkYQQCIGX+GF0PQjY8CWBC9KstfFeSg9ZeP2wxZi1QTZAYcFKg"}]},"maintainers":[{"name":"jdthorpe","email":"jdthorpe@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/winston-log-and-exit-1.0.0.tgz_1484936541276_0.8254167081322521"}},"1.0.1":{"name":"winston-log-and-exit","version":"1.0.1","description":"Patch for assuring that winston log messages are written to file before exiting","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/jdthorpe/winston-log-and-exit.git"},"keywords":["winston","exit","process.exit","flush"],"author":{"name":"Jason Thorpe"},"license":"MIT","bugs":{"url":"https://github.com/jdthorpe/winston-log-and-exit/issues"},"homepage":"https://github.com/jdthorpe/winston-log-and-exit#readme","gitHead":"839428416d444b326733a1c7ea22cc3d3eaeb9d8","_id":"winston-log-and-exit@1.0.1","_shasum":"2cc0c5cc955e465025733dec1247807b87858fc3","_from":".","_npmVersion":"3.10.9","_nodeVersion":"7.1.0","_npmUser":{"name":"jdthorpe","email":"jdthorpe@gmail.com"},"dist":{"shasum":"2cc0c5cc955e465025733dec1247807b87858fc3","tarball":"https://registry.npmjs.org/winston-log-and-exit/-/winston-log-and-exit-1.0.1.tgz","integrity":"sha512-pU2ZsSWzuiMQSXF3njmVP1hetT6aSp1/++f1zEIgEhD7k3X/LbRTVzXw1ja9iM0WFd94HIXbB9eO93gzLkfkbg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIC0E3QGs5jRZ9Atb7/cRnOWn7vVqQ/ejiFxtI2bauY3hAiEAylN2G0cO0lOOKKMcwlGJyifmeuejUoP0ET3vt2s3u/s="}]},"maintainers":[{"name":"jdthorpe","email":"jdthorpe@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/winston-log-and-exit-1.0.1.tgz_1485184517487_0.8016446803230792"}},"1.0.2":{"name":"winston-log-and-exit","version":"1.0.2","description":"Patch for assuring that winston log messages are written to file before exiting","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/jdthorpe/winston-log-and-exit.git"},"keywords":["winston","exit","process.exit","flush"],"author":{"name":"Jason Thorpe"},"license":"MIT","bugs":{"url":"https://github.com/jdthorpe/winston-log-and-exit/issues"},"homepage":"https://github.com/jdthorpe/winston-log-and-exit#readme","gitHead":"24c6fc2cf0de5af663b53f05d68535c9a87ddc0e","_id":"winston-log-and-exit@1.0.2","_shasum":"2b834c313aab3378979d0c22ecc70be13c5680df","_from":".","_npmVersion":"3.10.9","_nodeVersion":"7.1.0","_npmUser":{"name":"jdthorpe","email":"jdthorpe@gmail.com"},"dist":{"shasum":"2b834c313aab3378979d0c22ecc70be13c5680df","tarball":"https://registry.npmjs.org/winston-log-and-exit/-/winston-log-and-exit-1.0.2.tgz","integrity":"sha512-RrD05SJO6DFL5ytF0x5S5vGevS0kn1TBOfqgkLAfrJi2KLSoZexYtAzqnCMdMT5sZEXeHZvjBBDwRQI5aNwq6A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEX4mHwWLvVgAIbmyB2GepVL9qviZqk6YIFbQTxxfWN2AiArkEsnMVNpdbVr3iTJXqNiJcRN3i2uK8CQdOoyY+i5oA=="}]},"maintainers":[{"name":"jdthorpe","email":"jdthorpe@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/winston-log-and-exit-1.0.2.tgz_1485184705090_0.4244912138674408"}},"1.0.3":{"name":"winston-log-and-exit","version":"1.0.3","description":"Patch for assuring that winston log messages are written to file before exiting","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/jdthorpe/winston-log-and-exit.git"},"keywords":["winston","exit","process.exit","flush"],"author":{"name":"Jason Thorpe"},"license":"MIT","bugs":{"url":"https://github.com/jdthorpe/winston-log-and-exit/issues"},"homepage":"https://github.com/jdthorpe/winston-log-and-exit#readme","gitHead":"df11fb42e7884dfc9232be91a96971da156bc0b3","_id":"winston-log-and-exit@1.0.3","_shasum":"87c3b74c76cc574246a8274cbdbe105a26f2d8af","_from":".","_npmVersion":"3.10.9","_nodeVersion":"7.1.0","_npmUser":{"name":"jdthorpe","email":"jdthorpe@gmail.com"},"dist":{"shasum":"87c3b74c76cc574246a8274cbdbe105a26f2d8af","tarball":"https://registry.npmjs.org/winston-log-and-exit/-/winston-log-and-exit-1.0.3.tgz","integrity":"sha512-JBivvOYtL7TXW1aF3AiGP8A0LiWM+klvb07ZXcrcPwxSgyH+EQW59D/s+7FvbidAD+XAZYeQsM+opt4Yr+so2g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCNqzMhsabrqUEtq/1heN6qX3e1CCWHT2uvEUByejy99gIgZpRwY2w0/SP4fUi+onWX0QezxmkTdA/KG2L1Isa1FtU="}]},"maintainers":[{"name":"jdthorpe","email":"jdthorpe@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/winston-log-and-exit-1.0.3.tgz_1485184961710_0.3291415113490075"}},"1.0.4":{"name":"winston-log-and-exit","version":"1.0.4","description":"Patch for assuring that winston log messages are written to file before exiting","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/jdthorpe/winston-log-and-exit.git"},"keywords":["winston","exit","process.exit","flush"],"author":{"name":"Jason Thorpe"},"license":"MIT","bugs":{"url":"https://github.com/jdthorpe/winston-log-and-exit/issues"},"homepage":"https://github.com/jdthorpe/winston-log-and-exit#readme","gitHead":"e30cd350ac79c9cbc74b2b6c188bd97556f45b8e","_id":"winston-log-and-exit@1.0.4","_shasum":"8011aad83a6e34473b3443ff0d5e9ead7045439e","_from":".","_npmVersion":"3.10.9","_nodeVersion":"6.9.2","_npmUser":{"name":"jdthorpe","email":"jdthorpe@gmail.com"},"dist":{"shasum":"8011aad83a6e34473b3443ff0d5e9ead7045439e","tarball":"https://registry.npmjs.org/winston-log-and-exit/-/winston-log-and-exit-1.0.4.tgz","integrity":"sha512-Hj8cZyoE92p79tuDqe3nlWqSDxUqETsTux6BrNQpg/Qk4OKTWq7NVxbsSrP0Vnmb5pPprjDwMbmNeuOwcXtA9g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBK3+0GGO352EEx83oR/OT8FQBwpgjdXhOUQ7RGef2fXAiA10BNcEXe2QHK7Wb6B06RV/cxjWQpF+yUY0mZl746IhA=="}]},"maintainers":[{"name":"jdthorpe","email":"jdthorpe@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/winston-log-and-exit-1.0.4.tgz_1485380038397_0.8600437245331705"}},"1.0.5":{"name":"winston-log-and-exit","version":"1.0.5","description":"Patch for assuring that winston log messages are written to file before exiting","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/jdthorpe/winston-log-and-exit.git"},"keywords":["winston","exit","process.exit","flush"],"author":{"name":"Jason Thorpe"},"license":"MIT","bugs":{"url":"https://github.com/jdthorpe/winston-log-and-exit/issues"},"homepage":"https://github.com/jdthorpe/winston-log-and-exit#readme","gitHead":"c8fb60d82d2247197e7ddbc0800768ca8d942aa7","_id":"winston-log-and-exit@1.0.5","_shasum":"6e94bc308977a5d4860ae3e182bd6e91e88ef1b3","_from":".","_npmVersion":"3.10.9","_nodeVersion":"6.9.2","_npmUser":{"name":"jdthorpe","email":"jdthorpe@gmail.com"},"dist":{"shasum":"6e94bc308977a5d4860ae3e182bd6e91e88ef1b3","tarball":"https://registry.npmjs.org/winston-log-and-exit/-/winston-log-and-exit-1.0.5.tgz","integrity":"sha512-46o2FhDVLvFTVjfmkOyTFhLoAZDyCMOF2v4oIQ4DMBAaUHQWWEjM/cSMFeBAz+9E8bl18qit6NDCcdemW5q6Cg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDPTdm6D7CaK7NlkQ0VyoTL6t8MPl0yUFueIt0l1YzDhAIhAIY7ThVxL6qv+ZBr5dUwPRsqHQ1M+oIKCuOt+wl4DGYb"}]},"maintainers":[{"name":"jdthorpe","email":"jdthorpe@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/winston-log-and-exit-1.0.5.tgz_1485380539380_0.8226797161623836"}},"1.0.6":{"name":"winston-log-and-exit","version":"1.0.6","description":"Patch for assuring that winston log messages are written to file before exiting","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/jdthorpe/winston-log-and-exit.git"},"keywords":["winston","exit","process.exit","flush"],"author":{"name":"Jason Thorpe"},"license":"MIT","bugs":{"url":"https://github.com/jdthorpe/winston-log-and-exit/issues"},"homepage":"https://github.com/jdthorpe/winston-log-and-exit#readme","gitHead":"8c69b67aabe9b225392a039d34250e5ecd44e543","_id":"winston-log-and-exit@1.0.6","_shasum":"b68fd312c43b78f3384b4fd84a86c70fb59deaa3","_from":".","_npmVersion":"3.10.9","_nodeVersion":"6.9.2","_npmUser":{"name":"jdthorpe","email":"jdthorpe@gmail.com"},"dist":{"shasum":"b68fd312c43b78f3384b4fd84a86c70fb59deaa3","tarball":"https://registry.npmjs.org/winston-log-and-exit/-/winston-log-and-exit-1.0.6.tgz","integrity":"sha512-d4RNEEbS2ho4OFMd/hab6Lu1nbn65Cfz6bV55eoY4cx7aPY3qfPH9c6iK/nGTI8x03UOb29pnebxfXBvvWfR6w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDP1vF2wg60pD2ibgaKQQdnG+AhL6EHv60BCnhNBlIWxwIgAq6T06edSSDV1W4Uz/3o2+u1z1p3C20edokDD4LvIyg="}]},"maintainers":[{"name":"jdthorpe","email":"jdthorpe@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/winston-log-and-exit-1.0.6.tgz_1487609638335_0.4919182360172272"}}},"readme":"\r\n## The Problem\r\n\r\nWinston creates may execute logging callbacks before file streams have\r\nbeen flushed, and creates file streams asynchronously but executes the\r\nclose methods synchronously, and as a result, the following messages may\r\nnote be logged to file:\r\n\r\n    logger.info(\"This message may not be saved to file.\",\r\n        function(){process.exit()})\r\n\r\nand:\r\n\r\n    logger.info(\"This message probably won't be saved to file.\")\r\n    logger.close()\r\n    process.exit()\r\n\r\n## The solution\r\n\r\n`winston-log-and-exit` is a patch which adds a `log_and_exit()` (or\r\nequivalently `logAndExit()`) method to Winston, which can be used\r\nwith Winston's default logger like so:\r\n\r\n    var winston = require('winston');\r\n    require('winston-log-and-exit');\r\n\r\n    // add a file transport to winston's default logger\r\n    winston.add(winston.transports.File, { filename: 'somefile.log' });\r\n\r\n    winston.log_and_exit(/* log level */ \"info\" ,\r\n                         /* log text  */ \"This message *will* be included in the log files.\" ,\r\n                         /* exit code */ 0 )\r\n\r\n    winston.info(\"This message *might* be included in the log files.\")\r\n    process.nextTick(winston.info(\"This message probably won't be included in the log files.\")\r\n    setTimeout(winston.info(\"This message almost certianly won't be included in the log files.\"),100)\r\n\r\nand with a user-instantiated logger like so:\r\n\r\n    var winston = require('winston');\r\n    require('winston-log-and-exit');\r\n\r\n    var logger = new (winston.Logger)({\r\n        transports: [\r\n            new (winston.transports.Console)(),\r\n            new (winston.transports.File)({ filename: 'somefile.log' })\r\n        ]\r\n    });\r\n\r\n    logger.log_and_exit(\"info\",\"This message *will* be included in the log files.\",0)\r\n    logger.info(\"This message *might* be included in the log files.\")\r\n    process.nextTick(logger.info(\"This message probably won't be included in the log files.\")\r\n    setTimeout(logger.info(\"This message almost certianly won't be included in the log files.\"),100)\r\n\r\n\r\nThis can also be used to ensure that uncaught exceptions are logged:\r\n\r\n    require('winston-log-and-exit');\r\n    process.on('uncaughtException', function (err) {\r\n        // use `winston` or your own Logger instance as appropriate\r\n        winston.error(\"Uncaught Exception\",err);\r\n        winston.log_and_exit(\"info\",\"bye\",1);\r\n    });\r\n\r\nNote that the third argument may optionally be a callback which is\r\nresponsible for calling `process.exit()` (and if it doesn't, your begging\r\nfor a memory leak).\r\n\r\n    winston.log_and_exit(\"info\",\"bye\",function(){\r\n        try{\r\n            DB.close();\r\n            winston.log(\"This message will NOT get saved to file!\")\r\n        }finally{\r\n            process.exit(0);\r\n        }\r\n    });\r\n\r\n","maintainers":[{"name":"jdthorpe","email":"jdthorpe@gmail.com"}],"time":{"modified":"2022-06-29T02:23:55.991Z","created":"2017-01-20T18:22:23.135Z","1.0.0":"2017-01-20T18:22:23.135Z","1.0.1":"2017-01-23T15:15:19.267Z","1.0.2":"2017-01-23T15:18:26.757Z","1.0.3":"2017-01-23T15:22:41.933Z","1.0.4":"2017-01-25T21:33:58.638Z","1.0.5":"2017-01-25T21:42:19.621Z","1.0.6":"2017-02-20T16:53:58.574Z"},"homepage":"https://github.com/jdthorpe/winston-log-and-exit#readme","keywords":["winston","exit","process.exit","flush"],"repository":{"type":"git","url":"git+https://github.com/jdthorpe/winston-log-and-exit.git"},"author":{"name":"Jason Thorpe"},"bugs":{"url":"https://github.com/jdthorpe/winston-log-and-exit/issues"},"license":"MIT","readmeFilename":"README.md"}