{"id":312,"date":"2014-07-12T00:57:19","date_gmt":"2014-07-11T18:57:19","guid":{"rendered":"http:\/\/promincproductions.com\/blog\/?p=312"},"modified":"2014-11-01T22:00:05","modified_gmt":"2014-11-01T16:00:05","slug":"node-js-view-contents-object-console","status":"publish","type":"post","link":"https:\/\/promincproductions.com\/blog\/node-js-view-contents-object-console\/","title":{"rendered":"Node.JS &#8211; View contents of object in console"},"content":{"rendered":"<figure id=\"attachment_314\" aria-describedby=\"caption-attachment-314\" style=\"width: 500px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2014\/07\/nodejs-utility-object-console.png\" data-lasso-id=\"167\" data-rel=\"lightbox-gallery-8dZbglZp\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" class=\"size-medium wp-image-314\" src=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2014\/07\/nodejs-utility-object-console-500x171.png\" alt=\"Use the NodeJS Utility Module to display the contents of an object in the console logs\" width=\"500\" height=\"171\" srcset=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2014\/07\/nodejs-utility-object-console-500x171.png 500w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2014\/07\/nodejs-utility-object-console-768x263.png 768w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2014\/07\/nodejs-utility-object-console-1024x350.png 1024w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2014\/07\/nodejs-utility-object-console-150x51.png 150w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2014\/07\/nodejs-utility-object-console-600x205.png 600w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2014\/07\/nodejs-utility-object-console.png 1289w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><figcaption id=\"caption-attachment-314\" class=\"wp-caption-text\">Use the NodeJS Utility Module to display the contents of an object in the console logs<\/figcaption><\/figure>\n<p>When using Node.JS and you need to write to your log files what the contents of an OBJECT is, simply do the following:<\/p>\n<ul>\n<li>Require the Utility module at the setup of your script. \u00a0Put this at the top where you are requiring all of your other modules.\n<pre><code>var util = require('util');<\/code><\/pre>\n<\/li>\n<li>Then, where you want to view the contents of your object, simply use console.log with the utility.inspect function. \u00a0Here is an example:\n<pre class=\"lang-js prettyprint prettyprinted\"><code><span class=\"pln\">console<\/span><span class=\"pun\">.<\/span><span class=\"pln\">log<\/span><span class=\"pun\">( <\/span><span class=\"pln\">util<\/span><span class=\"pun\">.<\/span><span class=\"pln\">inspect<\/span><span class=\"pun\">( objectName <\/span><span class=\"pln\">) );<\/span><\/code><\/pre>\n<\/li>\n<\/ul>\n<p>Simple as that!<\/p>\n<p>The <a href=\"http:\/\/nodejs.org\/api\/util.html\" target=\"_blank\" data-lasso-id=\"168\" rel=\"noopener\">Utility module<\/a> offers many other features, but that&#8217;s to be explored another day.<\/p>","protected":false},"excerpt":{"rendered":"<p>When using Node.JS and you need to write to your log files what the contents of an OBJECT [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":314,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wprm-recipe-roundup-name":"","wprm-recipe-roundup-description":"","_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[12,52],"tags":[],"class_list":["post-312","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript-jquery","category-nodejs"],"jetpack_featured_media_url":"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2014\/07\/nodejs-utility-object-console.png","jetpack_shortlink":"https:\/\/wp.me\/p4BbcR-52","jetpack_sharing_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/posts\/312","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/comments?post=312"}],"version-history":[{"count":4,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/posts\/312\/revisions"}],"predecessor-version":[{"id":497,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/posts\/312\/revisions\/497"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/media\/314"}],"wp:attachment":[{"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/media?parent=312"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/categories?post=312"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/tags?post=312"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}