From bf5404506fefc5ddc055425f2136a6c684cb2586 Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Fri, 21 Nov 2014 09:50:12 +0000 Subject: [PATCH] Last part of MKWS-239. The core code's private _log() function now uses JavaScript's arguments pseudo-array to pass any sequence of arguments, varargs-like, into the underlying JSNLog functions. Unfortunately, it turns out that this doesn't get us anything right now, as those underlying functions expect a single argument -- so if you call mkws.info("found", n, "records"), it will only emit the string "found". For that reason, it's not worth the effort at this point to similarly varargsify the team-level logging, but I am leaving this one done so that the relevant code is in place when JSNLog gets updated. --- src/mkws-core.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/mkws-core.js b/src/mkws-core.js index 3087120..528ed94 100644 --- a/src/mkws-core.js +++ b/src/mkws-core.js @@ -114,7 +114,11 @@ var consoleAppender = JL.createConsoleAppender('consoleAppender'); mkws.logger.setOptions({ "appenders": [consoleAppender] }); -function _log(fn, string) { fn.call(mkws.logger, string); }; +function _log() { + var argsAsARealArray = Array.prototype.slice.call(arguments); + var fn = argsAsARealArray.shift(); + fn.apply(mkws.logger, argsAsARealArray); +}; mkws.trace = function(x) { _log(mkws.logger.trace, x) }; mkws.debug = function(x) { _log(mkws.logger.debug, x) }; mkws.info = function(x) { _log(mkws.logger.info, x) }; -- 1.7.10.4