Fix #119 - use util.inspect for logging objects

This commit is contained in:
Geraint White 2015-04-10 22:56:26 +01:00
parent 1f617ecdc5
commit 8b51cf67b5

View File

@ -33,6 +33,7 @@ module['exports'] = colors;
colors.themes = {};
var util = require('util');
var ansiStyles = colors.styles = require('./styles');
var defineProps = Object.defineProperties;
@ -87,14 +88,11 @@ var styles = (function () {
var proto = defineProps(function colors() {}, styles);
function applyStyle() {
var args = arguments;
var argsLen = args.length;
var str = argsLen !== 0 && String(arguments[0]);
if (argsLen > 1) {
for (var a = 1; a < argsLen; a++) {
str += ' ' + args[a];
}
}
var args = Array.prototype.slice.call(arguments);
var str = args.map(function(arg) {
return typeof arg === 'object' ? util.inspect(arg) : arg;
}).join(' ');
if (!colors.enabled || !str) {
return str;