I have a utility function that wraps console.log with a condition, so we only call console.log if we're in the dev environment and console.log exists:
/* Console log if environment has debug true or #debug initially passed in URL */
metro.conlog = (function () {
return function (message) {
if ((metro.siteData.debug || metro.hashOptions.hasOwnProperty('debug')) && window.console && message) {
console.log(message);
}
};
}());
This has worked very well for normal console logs. But I've recently discovered the joys of passing more than one argument to console.log: it allows you to prefix a console log with a string, so console.log('DEBUG', object) outputs the string plus an expandable object whose properties you can inspect. How can I change my conlog function to do this? I've tried logging out all arguments like this:
metro.conlog = (function () {
return function (message) {
if ((metro.siteData.debug || metro.hashOptions.hasOwnProperty('debug')) && window.console && message) {
console.log(arguments);
}
};
}());
But this outputs the arguments as an array, instead of the neat line you get with console.log. You can see the difference in this screenshot:

Can anybody tell me how I can reproduce the original log output?