From: Mike Taylor Date: Thu, 20 Nov 2014 14:37:33 +0000 (+0000) Subject: Repurpose the log_level setting to be the lowest level to emit. X-Git-Url: http://lists.indexdata.com/cgi-bin?a=commitdiff_plain;h=7b6b1d731e85c96c95101e444364eca4ab03782c;p=mkws-moved-to-github.git Repurpose the log_level setting to be the lowest level to emit. Can be any of 'trace', 'debug', 'info', 'warn', 'error' or 'fatal'. --- diff --git a/src/mkws-core.js b/src/mkws-core.js index 5cd500d..2b25807 100644 --- a/src/mkws-core.js +++ b/src/mkws-core.js @@ -3,7 +3,7 @@ * See the file LICENSE for details */ -"use strict"; // HTML5: disable for log_level >= 2 +"use strict"; // Set up global mkws object. Contains truly global state such as SP @@ -17,8 +17,7 @@ window.mkws = { authenticating: false, active: false, logger: undefined, - log_level: 1, // Will be overridden from mkws.config, but - // initial value allows jQuery popup to use logging. + log_level: "info", teams: {}, widgetType2function: {}, defaultTemplates: {}, @@ -91,9 +90,29 @@ if (typeof(mkws_jQuery) !== "undefined") { mkws.$ = jQuery; } +// It's ridiculous that JSNLog doesn't provide this +mkws.stringToLevel = function(s) { + if (s === 'trace') { + return JL.getTraceLevel(); + } else if (s === 'debug') { + return JL.getDebugLevel(); + } else if (s === 'info') { + return JL.getInfoLevel(); + } else if (s === 'warn') { + return JL.getWarnLevel(); + } else if (s === 'error') { + return JL.getErrorLevel(); + } else if (s === 'fatal') { + return JL.getFatalLevel(); + } else { + throw "bad log-level '" + s + "'"; + } +} + mkws.logger = JL('mkws'); var consoleAppender = JL.createConsoleAppender('consoleAppender'); -mkws.logger.setOptions({ "appenders": [consoleAppender]} ); +mkws.logger.setOptions({ "appenders": [consoleAppender], + "level": mkws.stringToLevel(mkws.log_level) }); function _log(fn, string) {