{"_id":"log-switch","_rev":"27-232b8f762edd42ad8ca71119741396e3","name":"log-switch","description":"help switch log function","dist-tags":{"latest":"0.0.3"},"versions":{"0.0.1":{"name":"log-switch","version":"0.0.1","description":"help switch log function","main":"logSwitch.js","scripts":{},"repository":{"type":"git","url":"https://github.com/Lellansin/logSwitch"},"keywords":["json"],"author":{"name":"Lellansin"},"license":"BSD","bugs":{"url":"https://github.com/Lellansin/logSwitch/issues"},"_id":"log-switch@0.0.1","dist":{"shasum":"01dcf9474e3ff5094d48b89c3a68e87d89e23cf4","tarball":"https://registry.npmjs.org/log-switch/-/log-switch-0.0.1.tgz","integrity":"sha512-WvmSjnv+qX0S1AK4wrQ9rfpMP+botAWkCTiV7mais88WIN2v74YydiS3IpzyVffAPq3a0Z3QuuM6NsjJm6KZRA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFoVZT3sYWYcRWxvQWxP7bZ22z4WLtYw1KxVUZ0Fr+DNAiEA8EqpjXh63pcJwZhx9NnN3dxBe/Z5pZMN7c42qVcN4Ek="}]},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"lellansin","email":"lellansin@gmail.com"},"maintainers":[{"name":"lellansin","email":"lellansin@gmail.com"}],"directories":{}},"0.0.2":{"name":"log-switch","version":"0.0.2","description":"help switch log function","main":"logSwitch.js","scripts":{},"repository":{"type":"git","url":"https://github.com/Lellansin/logSwitch"},"keywords":["console.log","log","disable log"],"author":{"name":"Lellansin"},"license":"BSD","bugs":{"url":"https://github.com/Lellansin/logSwitch/issues"},"_id":"log-switch@0.0.2","dist":{"shasum":"162c2d9860d89c43a6aa852bd33024c7c19b1955","tarball":"https://registry.npmjs.org/log-switch/-/log-switch-0.0.2.tgz","integrity":"sha512-/ykcYKYVXtubtneqCQkxfFW4Ass8ZDXMDXJ7CQLww4TQrVl2LT/EZXbdMjtMiB1YtsQ2cqTuQrtc1/Y4ezWMaw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICj6uzyTeKgO8sTqwVXXnFaxW9kNYa/AC1aMXkCHmKefAiAaC56YYvvoT5OsXIEP9GhzYp5xn/qxyMawNqpmo6JQEA=="}]},"_from":".","_resolved":"https://registry.npmjs.org/log-switch/-/log-switch-0.0.2.tgz","_npmVersion":"1.3.11","_npmUser":{"name":"lellansin","email":"lellansin@gmail.com"},"maintainers":[{"name":"lellansin","email":"lellansin@gmail.com"}],"directories":{}},"0.0.3":{"name":"log-switch","version":"0.0.3","description":"help switch log function","main":"logSwitch.js","scripts":{},"repository":{"type":"git","url":"https://github.com/Lellansin/logSwitch"},"keywords":["log","console.log","disable log","tracl log"],"author":{"name":"Lellansin"},"license":"BSD","bugs":{"url":"https://github.com/Lellansin/logSwitch/issues"},"_id":"log-switch@0.0.3","dist":{"shasum":"a7d1a4fd0bfe73b9125a27508ad4e565261983d4","tarball":"https://registry.npmjs.org/log-switch/-/log-switch-0.0.3.tgz","integrity":"sha512-vd/20Cl/wUF88fGSvnqSTkjC7K9UHnIDkVJFc8xlbKzfVOR1AXnllY3y9H/3/CP/i0g5pA39pbtUB3xZ1XXqNg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHWwP78YzVNoGwYknLPoyfo5TnjztolKTEAv2pDxaEdXAiEAvcsJFZDkwhkFWDkq64oXoVXF6qJjmiB3XwAj8gUIysQ="}]},"_from":".","_npmVersion":"1.3.5","_npmUser":{"name":"lellansin","email":"lellansin@gmail.com"},"maintainers":[{"name":"lellansin","email":"lellansin@gmail.com"}]}},"readme":"\r\nLog Switch\r\n------------\r\n\r\nWhat's the problem?\r\n---------------------\r\n\r\nThe problem is so many logs in my program.\r\n\r\n    for (var i = 0; i < 100000; i++) {\r\n      console.log('hello %d', i);\r\n    }\r\n\r\n`Result`\r\n\r\n    hello 0\r\n    hello 1\r\n    ...\r\n    hello 99998\r\n    hello 99999\r\n    [Finished in 40.6s]\r\n\r\nAs you see the info, call the console.log 100,000 times takes `40.6` second. that's so bad.\r\n\r\nDisable console.log\r\n---------------------\r\n\r\nTo avoid this situation, you can use LogSwitch to disable it.\r\n\r\n    var logs = require('log-switch');\r\n    \r\n    logs.disable();\r\n    \r\n    for (var i = 0; i < 100000; i++) {\r\n      console.log('hello %d', i);\r\n    }\r\n    \r\n    logs.restore();\r\n    \r\n    console.log('over');\r\n\r\n`Result`\r\n\r\n    over\r\n    [Finished in 0.2s]\r\n\r\n\r\nAuto enable logs\r\n---------------------\r\n\r\nIn case the error thrown, LogsSwitch can auto print the last 10 logs.\r\n\r\n    var logs = require('./log-switch');\r\n    \r\n    logs.setQueueLength(10);\r\n    logs.disable();\r\n    \r\n    function test() {\r\n      for (var i = 0; i < 100000; i++) {\r\n        if (i === 50000) {\r\n          throw new Error('Error string');\r\n        }\r\n        console.log('hello %d', i);\r\n      }\r\n    }\r\n    \r\n    test();\r\n\r\n`Result`\r\n\r\n    hello 49989\r\n    hello 49990\r\n    hello 49991\r\n    hello 49992\r\n    hello 49993\r\n    hello 49994\r\n    hello 49995\r\n    hello 49996\r\n    hello 49997\r\n    hello 49998\r\n    hello 49999\r\n    \r\n    F:\\node\\log-switch\\test.js:9\r\n          throw new Error('Error string');\r\n          ^\r\n    Error: Error string\r\n        at Error (<anonymous>)\r\n        at new Error (F:\\node\\node_modules\\log-switch\\logSwitch.js:81:24)\r\n        at test (F:\\node\\log-switch\\test.js:9:13)\r\n        at Object.<anonymous> (F:\\node\\log-switch\\test.js:15:1)\r\n        at Module._compile (module.js:456:26)\r\n        at Object.Module._extensions..js (module.js:474:10)\r\n        at Module.load (module.js:356:32)\r\n        at Function.Module._load (module.js:312:12)\r\n        at Function.Module.runMain (module.js:497:10)\r\n        at startup (node.js:119:16)\r\n        at node.js:901:3\r\n    [Finished in 0.2s with exit code 8]\r\n\r\n\r\nTrack logs\r\n---------------------\r\n\r\ntrack-test.js\r\n     \r\n    function test() {\r\n        console.log('where is this log?');\r\n    }\r\n    \r\n    function twiceCall() {\r\n        console.log('second file')\r\n        test();\r\n    }\r\n    \r\n    exports.twiceCall = twiceCall;\r\n\r\nt.js\r\n\r\n    var logs = require('log-switch');\r\n    var twiceCall = require('./track-test').twiceCall;\r\n    \r\n    logs.track();\r\n    console.log('first file');\r\n    twiceCall();\r\n    \r\n    logs.restore(); // disable the track\r\n\r\n`Result`\r\n\r\n    first file\r\n      at  (F:\\node\\log-switch\\t.js:4)\r\n    second file\r\n      at twiceCall (F:\\node\\log-switch\\track-test.js:10)\r\n    where is this log?\r\n      at test (F:\\node\\log-switch\\track-test.js:6)\r\n    [Finished in 0.2s]\r\n\r\n\r\nTest computer\r\n--------------------\r\n\r\nThe test data `40.6` second is comes from:\r\n\r\n        OS    :  Microsoft Windows 7 Ultimate (x64)\r\n    Processor :  AMD64 Family 16 Model 6 Stepping 3 AuthenticAMD ~3000 Mhz","maintainers":[{"name":"lellansin","email":"lellansin@gmail.com"}],"time":{"modified":"2022-06-19T13:45:37.615Z","created":"2013-11-29T07:05:12.827Z","0.0.1":"2013-11-29T07:05:25.792Z","0.0.2":"2013-12-02T03:10:59.803Z","0.0.3":"2013-12-16T10:14:45.440Z"},"author":{"name":"Lellansin"},"repository":{"type":"git","url":"https://github.com/Lellansin/logSwitch"},"users":{"fgribreau":true,"tyler_jd":true},"keywords":["log","console.log","disable log","tracl log"],"bugs":{"url":"https://github.com/Lellansin/logSwitch/issues"},"license":"BSD","readmeFilename":"README.md"}