Skip to content

Commit

Permalink
Fix long-standing, low-priority (but super annoying) issue with logge…
Browse files Browse the repository at this point in the history
…d dictionaries/arrays getting extra quote marks (due to a pecularity in the usage of util.format(), and me not being careful enough in write().
  • Loading branch information
mikermcneil committed Jul 27, 2016
1 parent 94e5cda commit d67e9c8
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/write.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,22 @@ module.exports = function(logFn, logAt, options) {

// Combine the arguments passed into the log fn
var pieces = [];
_.each(arguments, function(arg) {
_.each(args, function(arg) {

// Your everyday JavaScript errors
if (_.isError(arg) && arg.stack && !arg.inspect) {
pieces.push(arg.stack);
}
// Miscellaneous arrays, dictionaries, and mysterious objects.
else if (_.isObject(arg)) {
// Non-strings
// (miscellaneous arrays, dictionaries, mysterious objects, etc)
else if (!_.isString(arg)) {
if (options.inspectOptions) {
pieces.push(util.inspect(arg, options.inspectOptions));
}
else { pieces.push(util.inspect(arg)); }
return;
}
// Everything else (strings, numbers, booleans, null, undefined, all that stuff.)
// Strings
else {
pieces.push(arg);
}
Expand Down

0 comments on commit d67e9c8

Please sign in to comment.