From 224fafdf19039e89d6f658753b2318add4c13923 Mon Sep 17 00:00:00 2001 From: yofreke Date: Sun, 29 Nov 2015 04:26:18 -0800 Subject: [PATCH] fix logging a single object --- src/web/util/ConsoleLogger.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/web/util/ConsoleLogger.js b/src/web/util/ConsoleLogger.js index 14d1b57f..72c8dc2d 100644 --- a/src/web/util/ConsoleLogger.js +++ b/src/web/util/ConsoleLogger.js @@ -21,6 +21,8 @@ var Logger = Class(function() { }; this._doLog = function(fn, level, args) { + // ensure args is an array object + args = Array.prototype.slice.call(args); var interp = []; var prefix = '%c[' + this._name + ']'; @@ -38,10 +40,19 @@ var Logger = Class(function() { prefix += '\t%c'; interp.push('color: black'); - var _args = [prefix + args[0]].concat(interp); + var _args = [prefix]; + if (typeof args[0] === 'string') { + _args[0] += args[0]; + _args = _args.concat(interp); + } else { + _args = _args.concat(interp); + _args.push(args[0]); + } + if (args.length > 1) { _args = _args.concat(Array.prototype.slice.call(args, 1)); } + fn.apply(console, _args); };