From 26d6dcebe58f40311e2f42d9cd664161eed15a72 Mon Sep 17 00:00:00 2001 From: Dylan Mikus Date: Mon, 15 Dec 2014 17:39:32 -0500 Subject: [PATCH] Do not log object properties that are functions and try JSON.stringify before checking for undefined. --- lib/prettystream.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/prettystream.js b/lib/prettystream.js index fe98ed6..3671e97 100644 --- a/lib/prettystream.js +++ b/lib/prettystream.js @@ -312,12 +312,18 @@ function PrettyStream(opts){ Object.keys(rec).forEach(function(key) { if (skip.indexOf(key) === -1){ var value = rec[key]; - if (typeof value === 'undefined') value = ''; var stringified = false; + if (typeof value === 'function') { + return; + } if (typeof value !== 'string') { value = JSON.stringify(value, null, 2); stringified = true; } + if (typeof value === 'undefined') { + value = ''; + stringified = false; + } if (value.indexOf('\n') !== -1 || value.length > 50) { details.push(key + ': ' + value); } else if (!stringified && (value.indexOf(' ') != -1 || value.length === 0)){