{"id":535,"date":"2013-03-19T13:19:13","date_gmt":"2013-03-19T13:19:13","guid":{"rendered":"http:\/\/www.eddiedillon.info\/?p=535"},"modified":"2013-03-19T13:20:10","modified_gmt":"2013-03-19T13:20:10","slug":"add-some-sweet-logging-to-your-javascriptnode-js-apps-with-winston","status":"publish","type":"post","link":"https:\/\/www.eddiedillon.info\/?p=535","title":{"rendered":"Add some sweet logging to your Javascript\/Node.js apps with Winston"},"content":{"rendered":"            <script type=\"text\/javascript\" src=\"https:\/\/www.eddiedillon.info\/wp-content\/plugins\/wordpress-code-snippet\/scripts\/shBrushJScript.js\"><\/script>\n<p>If you are looking for a logging solution to your javascript or node.js apps, look no further, enter Winston. \u00a0This little tool can write logs from your apps to a file, to the console, or to a database and you can even query the logs with its own built in syntax, how sweet is that? \u00a0Anyways, I have included below the code snippets that is needed to get it going, check it out:<\/p>\n<p><pre class=\"brush: js\">\/\/by default, Winston is set to log to console \r\nvar winston = require(&#039;winston&#039;);\r\n\r\n winston.log(&#039;info&#039;, &#039;Hello distributed log files!&#039;);\r\n winston.info(&#039;Hello again distributed logs&#039;);\r\n\r\n\/\/you can change that behavior by doing something like this:\r\nwinston.add(winston.transports.File, { filename: &#039;somefile.log&#039; });\r\nwinston.remove(winston.transports.Console);\r\n<\/pre><\/p>\n<p>Here is the github repo for further reading if you are considering this tool <a href=\"https:\/\/github.com\/flatiron\/winston\">https:\/\/github.com\/flatiron\/winston<\/a><\/p>\n<p>Pretty simple, just three lines of code and you are logging, just slap a winston.info() anywhere you want to see some info and you are good to go, enjoy!!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you are looking for a logging solution to your javascript or node.js apps, look no further, enter Winston. \u00a0This little tool can write logs from your apps to a file, to the console, or to a database and you can even query the logs with its own built in syntax, how sweet is that? [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[38,120],"tags":[],"_links":{"self":[{"href":"https:\/\/www.eddiedillon.info\/index.php?rest_route=\/wp\/v2\/posts\/535"}],"collection":[{"href":"https:\/\/www.eddiedillon.info\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.eddiedillon.info\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.eddiedillon.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.eddiedillon.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=535"}],"version-history":[{"count":3,"href":"https:\/\/www.eddiedillon.info\/index.php?rest_route=\/wp\/v2\/posts\/535\/revisions"}],"predecessor-version":[{"id":538,"href":"https:\/\/www.eddiedillon.info\/index.php?rest_route=\/wp\/v2\/posts\/535\/revisions\/538"}],"wp:attachment":[{"href":"https:\/\/www.eddiedillon.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=535"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.eddiedillon.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=535"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.eddiedillon.info\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=535"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}