Skip to content

Commit

Permalink
options.prettyPrint can now be a function
Browse files Browse the repository at this point in the history
If options.prettyPrint is a function, meta will be run through it before appending to output.
  • Loading branch information
zuk authored and Matt Zukowski committed Jul 2, 2013
1 parent 2c93353 commit 2f5f296
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/winston/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,13 @@ exports.log = function (options) {
output += ' ' + meta;
}
else if (Object.keys(meta).length > 0) {
output += ' ' + (
options.prettyPrint
? ('\n' + util.inspect(meta, false, null, options.colorize))
: exports.serialize(meta)
);
if (typeof options.prettyPrint === 'function') {
output += ' ' + options.prettyPrint(meta);
} else if (options.prettyPrint) {
output += ' ' + '\n' + util.inspect(meta, false, null, options.colorize);
} else {
output += ' ' + exports.serialize(meta);
}
}
}

Expand Down

0 comments on commit 2f5f296

Please sign in to comment.