Skip to content

Commit

Permalink
uninspected.(log|error|info|warn): Use the ColoredConsole serializer …
Browse files Browse the repository at this point in the history
…in Chrome.
  • Loading branch information
papandreou committed Dec 17, 2014
1 parent d4a4fe0 commit 4b8cb66
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/uninspected.js
Expand Up @@ -21,6 +21,12 @@ uninspected.defaultDepth = 4; // util's default level of 2 is annoyingly low
uninspected.output = unexpected.output;
uninspected.outputFormat = unexpected.outputFormat();

if (uninspected.outputFormat === 'html') {
uninspected.outputFormat = 'text';
}

var isChrome = typeof navigator !== 'undefined' && navigator && typeof navigator.userAgent === 'string' && /chrome/i.test(navigator.userAgent);

['log', 'info', 'warn', 'error'].forEach(function (methodName) {
uninspected[methodName] = function () { // ...
var output = uninspected.output.clone();
Expand All @@ -36,7 +42,11 @@ uninspected.outputFormat = unexpected.outputFormat();
output.append(unexpected.inspect(obj, uninspected.defaultDepth));
}
});
console[methodName](output.toString(uninspected.outputFormat));
if (isChrome) {
console[methodName].apply(console, output.toString('coloredConsole'));
} else {
console[methodName](output.toString(uninspected.outputFormat));
}
};
});

Expand Down

0 comments on commit 4b8cb66

Please sign in to comment.