From d457009418cc1aeef50c309c56b5d5661e3331b3 Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Wed, 24 Apr 2024 22:36:55 +0100 Subject: [PATCH] MDL-81659 libraries: upgrade to version 1.9.1 of loglevel. --- lib/amd/build/loglevel.min.js | 2 +- lib/amd/build/loglevel.min.js.map | 2 +- lib/amd/src/loglevel.js | 143 ++++++++++++++++++++++-------- lib/thirdpartylibs.xml | 2 +- 4 files changed, 107 insertions(+), 42 deletions(-) diff --git a/lib/amd/build/loglevel.min.js b/lib/amd/build/loglevel.min.js index 06e63992a60..976ffda0a9b 100644 --- a/lib/amd/build/loglevel.min.js +++ b/lib/amd/build/loglevel.min.js @@ -1,3 +1,3 @@ -var root,definition;root=window,definition=function(){var noop=function(){},isIE="undefined"!=typeof window&&void 0!==window.navigator&&/Trident\/|MSIE /.test(window.navigator.userAgent),logMethods=["trace","debug","info","warn","error"];function bindMethod(obj,methodName){var method=obj[methodName];if("function"==typeof method.bind)return method.bind(obj);try{return Function.prototype.bind.call(method,obj)}catch(e){return function(){return Function.prototype.apply.apply(method,[obj,arguments])}}}function traceForIE(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function realMethod(methodName){return"debug"===methodName&&(methodName="log"),"undefined"!=typeof console&&("trace"===methodName&&isIE?traceForIE:void 0!==console[methodName]?bindMethod(console,methodName):void 0!==console.log?bindMethod(console,"log"):noop)}function replaceLoggingMethods(level,loggerName){for(var i=0;i=0&&level<=self.levels.SILENT))throw"log.setLevel() called with invalid level: "+level;if(currentLevel=level,!1!==persist&&function(levelNum){var levelName=(logMethods[levelNum]||"silent").toUpperCase();if("undefined"!=typeof window&&storageKey){try{return void(window.localStorage[storageKey]=levelName)}catch(ignore){}try{window.document.cookie=encodeURIComponent(storageKey)+"="+levelName+";"}catch(ignore){}}}(level),replaceLoggingMethods.call(self,level,name),"undefined"==typeof console&&level=0&&level<=self.levels.SILENT)return level;throw new TypeError("log.setLevel() called with invalid level: "+input)}"string"==typeof name?storageKey+=":"+name:"symbol"==typeof name&&(storageKey=void 0),self.name=name,self.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},self.methodFactory=factory||defaultMethodFactory,self.getLevel=function(){return null!=userLevel?userLevel:null!=defaultLevel?defaultLevel:inheritedLevel},self.setLevel=function(level,persist){return userLevel=normalizeLevel(level),!1!==persist&&function(levelNum){var levelName=(logMethods[levelNum]||"silent").toUpperCase();if("undefined"!=typeof window&&storageKey){try{return void(window.localStorage[storageKey]=levelName)}catch(ignore){}try{window.document.cookie=encodeURIComponent(storageKey)+"="+levelName+";"}catch(ignore){}}}(userLevel),replaceLoggingMethods.call(self)},self.setDefaultLevel=function(level){defaultLevel=normalizeLevel(level),getPersistedLevel()||self.setLevel(level,!1)},self.resetLevel=function(){userLevel=null,function(){if("undefined"!=typeof window&&storageKey){try{window.localStorage.removeItem(storageKey)}catch(ignore){}try{window.document.cookie=encodeURIComponent(storageKey)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch(ignore){}}}(),replaceLoggingMethods.call(self)},self.enableAll=function(persist){self.setLevel(self.levels.TRACE,persist)},self.disableAll=function(persist){self.setLevel(self.levels.SILENT,persist)},self.rebuild=function(){if(defaultLogger!==self&&(inheritedLevel=normalizeLevel(defaultLogger.getLevel())),replaceLoggingMethods.call(self),defaultLogger===self)for(var childName in _loggersByName)_loggersByName[childName].rebuild()},inheritedLevel=normalizeLevel(defaultLogger?defaultLogger.getLevel():"WARN");var initialLevel=getPersistedLevel();null!=initialLevel&&(userLevel=normalizeLevel(initialLevel)),replaceLoggingMethods.call(self)}(defaultLogger=new Logger).getLogger=function(name){if("symbol"!=typeof name&&"string"!=typeof name||""===name)throw new TypeError("You must supply a name when creating a logger.");var logger=_loggersByName[name];return logger||(logger=_loggersByName[name]=new Logger(name,defaultLogger.methodFactory)),logger};var _log="undefined"!=typeof window?window.log:void 0;return defaultLogger.noConflict=function(){return"undefined"!=typeof window&&window.log===defaultLogger&&(window.log=_log),defaultLogger},defaultLogger.getLoggers=function(){return _loggersByName},defaultLogger.default=defaultLogger,defaultLogger},"function"==typeof define&&define.amd?define("core/loglevel",definition):"object"==typeof module&&module.exports?module.exports=definition():root.log=definition(); //# sourceMappingURL=loglevel.min.js.map \ No newline at end of file diff --git a/lib/amd/build/loglevel.min.js.map b/lib/amd/build/loglevel.min.js.map index 971545c5204..d3a610c2768 100644 --- a/lib/amd/build/loglevel.min.js.map +++ b/lib/amd/build/loglevel.min.js.map @@ -1 +1 @@ -{"version":3,"file":"loglevel.min.js","sources":["../src/loglevel.js"],"sourcesContent":["// Copyright (c) 2013 Tim Perry\n//\n// Permission is hereby granted, free of charge, to any person\n// obtaining a copy of this software and associated documentation\n// files (the \"Software\"), to deal in the Software without\n// restriction, including without limitation the rights to use,\n// copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the\n// Software is furnished to do so, subject to the following\n// conditions:\n//\n// The above copyright notice and this permission notice shall be\n// included in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n// OTHER DEALINGS IN THE SOFTWARE.\n\n// Description of import into Moodle:\n// Download from https://github.com/pimterry/loglevel/tree/master/dist\n// Copy loglevel.js into lib/amd/src/ in Moodle folder.\n// Add the license as a comment to the file and these instructions.\n\n/*! loglevel - v1.8.1 - https://github.com/pimterry/loglevel - (c) 2022 Tim Perry - licensed MIT */\n(function (root, definition) {\n \"use strict\";\n if (typeof define === 'function' && define.amd) {\n define(definition);\n } else if (typeof module === 'object' && module.exports) {\n module.exports = definition();\n } else {\n root.log = definition();\n }\n}(this, function () {\n \"use strict\";\n\n // Slightly dubious tricks to cut down minimized file size\n var noop = function() {};\n var undefinedType = \"undefined\";\n var isIE = (typeof window !== undefinedType) && (typeof window.navigator !== undefinedType) && (\n /Trident\\/|MSIE /.test(window.navigator.userAgent)\n );\n\n var logMethods = [\n \"trace\",\n \"debug\",\n \"info\",\n \"warn\",\n \"error\"\n ];\n\n // Cross-browser bind equivalent that works at least back to IE6\n function bindMethod(obj, methodName) {\n var method = obj[methodName];\n if (typeof method.bind === 'function') {\n return method.bind(obj);\n } else {\n try {\n return Function.prototype.bind.call(method, obj);\n } catch (e) {\n // Missing bind shim or IE8 + Modernizr, fallback to wrapping\n return function() {\n return Function.prototype.apply.apply(method, [obj, arguments]);\n };\n }\n }\n }\n\n // Trace() doesn't print the message in IE, so for that case we need to wrap it\n function traceForIE() {\n if (console.log) {\n if (console.log.apply) {\n console.log.apply(console, arguments);\n } else {\n // In old IE, native console methods themselves don't have apply().\n Function.prototype.apply.apply(console.log, [console, arguments]);\n }\n }\n if (console.trace) console.trace();\n }\n\n // Build the best logging method possible for this env\n // Wherever possible we want to bind, not wrap, to preserve stack traces\n function realMethod(methodName) {\n if (methodName === 'debug') {\n methodName = 'log';\n }\n\n if (typeof console === undefinedType) {\n return false; // No method possible, for now - fixed later by enableLoggingWhenConsoleArrives\n } else if (methodName === 'trace' && isIE) {\n return traceForIE;\n } else if (console[methodName] !== undefined) {\n return bindMethod(console, methodName);\n } else if (console.log !== undefined) {\n return bindMethod(console, 'log');\n } else {\n return noop;\n }\n }\n\n // These private functions always need `this` to be set properly\n\n function replaceLoggingMethods(level, loggerName) {\n /*jshint validthis:true */\n for (var i = 0; i < logMethods.length; i++) {\n var methodName = logMethods[i];\n this[methodName] = (i < level) ?\n noop :\n this.methodFactory(methodName, level, loggerName);\n }\n\n // Define log.log as an alias for log.debug\n this.log = this.debug;\n }\n\n // In old IE versions, the console isn't present until you first open it.\n // We build realMethod() replacements here that regenerate logging methods\n function enableLoggingWhenConsoleArrives(methodName, level, loggerName) {\n return function () {\n if (typeof console !== undefinedType) {\n replaceLoggingMethods.call(this, level, loggerName);\n this[methodName].apply(this, arguments);\n }\n };\n }\n\n // By default, we use closely bound real methods wherever possible, and\n // otherwise we wait for a console to appear, and then try again.\n function defaultMethodFactory(methodName, level, loggerName) {\n /*jshint validthis:true */\n return realMethod(methodName) ||\n enableLoggingWhenConsoleArrives.apply(this, arguments);\n }\n\n function Logger(name, defaultLevel, factory) {\n var self = this;\n var currentLevel;\n defaultLevel = defaultLevel == null ? \"WARN\" : defaultLevel;\n\n var storageKey = \"loglevel\";\n if (typeof name === \"string\") {\n storageKey += \":\" + name;\n } else if (typeof name === \"symbol\") {\n storageKey = undefined;\n }\n\n function persistLevelIfPossible(levelNum) {\n var levelName = (logMethods[levelNum] || 'silent').toUpperCase();\n\n if (typeof window === undefinedType || !storageKey) return;\n\n // Use localStorage if available\n try {\n window.localStorage[storageKey] = levelName;\n return;\n } catch (ignore) {}\n\n // Use session cookie as fallback\n try {\n window.document.cookie =\n encodeURIComponent(storageKey) + \"=\" + levelName + \";\";\n } catch (ignore) {}\n }\n\n function getPersistedLevel() {\n var storedLevel;\n\n if (typeof window === undefinedType || !storageKey) return;\n\n try {\n storedLevel = window.localStorage[storageKey];\n } catch (ignore) {}\n\n // Fallback to cookies if local storage gives us nothing\n if (typeof storedLevel === undefinedType) {\n try {\n var cookie = window.document.cookie;\n var location = cookie.indexOf(\n encodeURIComponent(storageKey) + \"=\");\n if (location !== -1) {\n storedLevel = /^([^;]+)/.exec(cookie.slice(location))[1];\n }\n } catch (ignore) {}\n }\n\n // If the stored level is not valid, treat it as if nothing was stored.\n if (self.levels[storedLevel] === undefined) {\n storedLevel = undefined;\n }\n\n return storedLevel;\n }\n\n function clearPersistedLevel() {\n if (typeof window === undefinedType || !storageKey) return;\n\n // Use localStorage if available\n try {\n window.localStorage.removeItem(storageKey);\n return;\n } catch (ignore) {}\n\n // Use session cookie as fallback\n try {\n window.document.cookie =\n encodeURIComponent(storageKey) + \"=; expires=Thu, 01 Jan 1970 00:00:00 UTC\";\n } catch (ignore) {}\n }\n\n /*\n *\n * Public logger API - see https://github.com/pimterry/loglevel for details\n *\n */\n\n self.name = name;\n\n self.levels = { \"TRACE\": 0, \"DEBUG\": 1, \"INFO\": 2, \"WARN\": 3,\n \"ERROR\": 4, \"SILENT\": 5};\n\n self.methodFactory = factory || defaultMethodFactory;\n\n self.getLevel = function () {\n return currentLevel;\n };\n\n self.setLevel = function (level, persist) {\n if (typeof level === \"string\" && self.levels[level.toUpperCase()] !== undefined) {\n level = self.levels[level.toUpperCase()];\n }\n if (typeof level === \"number\" && level >= 0 && level <= self.levels.SILENT) {\n currentLevel = level;\n if (persist !== false) { // defaults to true\n persistLevelIfPossible(level);\n }\n replaceLoggingMethods.call(self, level, name);\n if (typeof console === undefinedType && level < self.levels.SILENT) {\n return \"No console available for logging\";\n }\n } else {\n throw \"log.setLevel() called with invalid level: \" + level;\n }\n };\n\n self.setDefaultLevel = function (level) {\n defaultLevel = level;\n if (!getPersistedLevel()) {\n self.setLevel(level, false);\n }\n };\n\n self.resetLevel = function () {\n self.setLevel(defaultLevel, false);\n clearPersistedLevel();\n };\n\n self.enableAll = function(persist) {\n self.setLevel(self.levels.TRACE, persist);\n };\n\n self.disableAll = function(persist) {\n self.setLevel(self.levels.SILENT, persist);\n };\n\n // Initialize with the right level\n var initialLevel = getPersistedLevel();\n if (initialLevel == null) {\n initialLevel = defaultLevel;\n }\n self.setLevel(initialLevel, false);\n }\n\n /*\n *\n * Top-level API\n *\n */\n\n var defaultLogger = new Logger();\n\n var _loggersByName = {};\n defaultLogger.getLogger = function getLogger(name) {\n if ((typeof name !== \"symbol\" && typeof name !== \"string\") || name === \"\") {\n throw new TypeError(\"You must supply a name when creating a logger.\");\n }\n\n var logger = _loggersByName[name];\n if (!logger) {\n logger = _loggersByName[name] = new Logger(\n name, defaultLogger.getLevel(), defaultLogger.methodFactory);\n }\n return logger;\n };\n\n // Grab the current global log variable in case of overwrite\n var _log = (typeof window !== undefinedType) ? window.log : undefined;\n defaultLogger.noConflict = function() {\n if (typeof window !== undefinedType &&\n window.log === defaultLogger) {\n window.log = _log;\n }\n\n return defaultLogger;\n };\n\n defaultLogger.getLoggers = function getLoggers() {\n return _loggersByName;\n };\n\n // ES6 default export, for compatibility\n defaultLogger['default'] = defaultLogger;\n\n return defaultLogger;\n}));\n"],"names":["root","definition","this","noop","isIE","window","navigator","test","userAgent","logMethods","bindMethod","obj","methodName","method","bind","Function","prototype","call","e","apply","arguments","traceForIE","console","log","trace","realMethod","undefined","replaceLoggingMethods","level","loggerName","i","length","methodFactory","debug","enableLoggingWhenConsoleArrives","defaultMethodFactory","Logger","name","defaultLevel","factory","currentLevel","self","storageKey","getPersistedLevel","storedLevel","localStorage","ignore","cookie","document","location","indexOf","encodeURIComponent","exec","slice","levels","getLevel","setLevel","persist","toUpperCase","SILENT","levelNum","levelName","persistLevelIfPossible","setDefaultLevel","resetLevel","removeItem","clearPersistedLevel","enableAll","TRACE","disableAll","initialLevel","defaultLogger","_loggersByName","getLogger","TypeError","logger","_log","noConflict","getLoggers","define","amd","module","exports"],"mappings":"AA6BC,IAAUA,KAAMC,WAAND,KASTE,OATeD,WAST,eAIAE,KAAO,aAEPC,KADgB,oBACDC,aADC,IACoCA,OAAOC,WAC3D,kBAAkBC,KAAKF,OAAOC,UAAUE,WAGxCC,WAAa,CACb,QACA,QACA,OACA,OACA,kBAIKC,WAAWC,IAAKC,gBACjBC,OAASF,IAAIC,eACU,mBAAhBC,OAAOC,YACPD,OAAOC,KAAKH,gBAGRI,SAASC,UAAUF,KAAKG,KAAKJ,OAAQF,KAC9C,MAAOO,UAEE,kBACIH,SAASC,UAAUG,MAAMA,MAAMN,OAAQ,CAACF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c,cAAc,OAS1BC,cAAgB,IAAInC,OAEpBoC,eAAiB,GACrBD,cAAcE,UAAY,SAAmBpC,SACpB,iBAATA,MAAqC,iBAATA,MAA+B,KAATA,WACtD,IAAIqC,UAAU,sDAGlBC,OAASH,eAAenC,aACvBsC,SACHA,OAASH,eAAenC,MAAQ,IAAID,OAClCC,KAAMkC,cAAchB,WAAYgB,cAAcvC,gBAE3C2C,YAIPC,KAlQgB,oBAkQDvE,OAA4BA,OAAOkB,SAAMG,SAC5D6C,cAAcM,WAAa,iBAnQP,oBAoQLxE,QACJA,OAAOkB,MAAQgD,gBAClBlE,OAAOkB,IAAMqD,MAGVL,eAGXA,cAAcO,WAAa,kBAChBN,gBAIXD,cAAa,QAAcA,cAEpBA,eA/Re,mBAAXQ,QAAyBA,OAAOC,IACvCD,uBAAO9E,YACkB,iBAAXgF,QAAuBA,OAAOC,QAC5CD,OAAOC,QAAUjF,aAEjBD,KAAKuB,IAAMtB"} \ No newline at end of file +{"version":3,"file":"loglevel.min.js","sources":["../src/loglevel.js"],"sourcesContent":["// Copyright (c) 2013 Tim Perry\n//\n// Permission is hereby granted, free of charge, to any person\n// obtaining a copy of this software and associated documentation\n// files (the \"Software\"), to deal in the Software without\n// restriction, including without limitation the rights to use,\n// copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the\n// Software is furnished to do so, subject to the following\n// conditions:\n//\n// The above copyright notice and this permission notice shall be\n// included in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n// OTHER DEALINGS IN THE SOFTWARE.\n\n// Description of import into Moodle:\n// Download from https://github.com/pimterry/loglevel/tree/master/dist\n// Copy loglevel.js into lib/amd/src/ in Moodle folder.\n// Add the license as a comment to the file and these instructions.\n\n/*\n* loglevel - https://github.com/pimterry/loglevel\n*\n* Copyright (c) 2013 Tim Perry\n* Licensed under the MIT license.\n*/\n(function (root, definition) {\n \"use strict\";\n if (typeof define === 'function' && define.amd) {\n define(definition);\n } else if (typeof module === 'object' && module.exports) {\n module.exports = definition();\n } else {\n root.log = definition();\n }\n}(this, function () {\n \"use strict\";\n\n // Slightly dubious tricks to cut down minimized file size\n var noop = function() {};\n var undefinedType = \"undefined\";\n var isIE = (typeof window !== undefinedType) && (typeof window.navigator !== undefinedType) && (\n /Trident\\/|MSIE /.test(window.navigator.userAgent)\n );\n\n var logMethods = [\n \"trace\",\n \"debug\",\n \"info\",\n \"warn\",\n \"error\"\n ];\n\n var _loggersByName = {};\n var defaultLogger = null;\n\n // Cross-browser bind equivalent that works at least back to IE6\n function bindMethod(obj, methodName) {\n var method = obj[methodName];\n if (typeof method.bind === 'function') {\n return method.bind(obj);\n } else {\n try {\n return Function.prototype.bind.call(method, obj);\n } catch (e) {\n // Missing bind shim or IE8 + Modernizr, fallback to wrapping\n return function() {\n return Function.prototype.apply.apply(method, [obj, arguments]);\n };\n }\n }\n }\n\n // Trace() doesn't print the message in IE, so for that case we need to wrap it\n function traceForIE() {\n if (console.log) {\n if (console.log.apply) {\n console.log.apply(console, arguments);\n } else {\n // In old IE, native console methods themselves don't have apply().\n Function.prototype.apply.apply(console.log, [console, arguments]);\n }\n }\n if (console.trace) console.trace();\n }\n\n // Build the best logging method possible for this env\n // Wherever possible we want to bind, not wrap, to preserve stack traces\n function realMethod(methodName) {\n if (methodName === 'debug') {\n methodName = 'log';\n }\n\n if (typeof console === undefinedType) {\n return false; // No method possible, for now - fixed later by enableLoggingWhenConsoleArrives\n } else if (methodName === 'trace' && isIE) {\n return traceForIE;\n } else if (console[methodName] !== undefined) {\n return bindMethod(console, methodName);\n } else if (console.log !== undefined) {\n return bindMethod(console, 'log');\n } else {\n return noop;\n }\n }\n\n // These private functions always need `this` to be set properly\n\n function replaceLoggingMethods() {\n /*jshint validthis:true */\n var level = this.getLevel();\n\n // Replace the actual methods.\n for (var i = 0; i < logMethods.length; i++) {\n var methodName = logMethods[i];\n this[methodName] = (i < level) ?\n noop :\n this.methodFactory(methodName, level, this.name);\n }\n\n // Define log.log as an alias for log.debug\n this.log = this.debug;\n\n // Return any important warnings.\n if (typeof console === undefinedType && level < this.levels.SILENT) {\n return \"No console available for logging\";\n }\n }\n\n // In old IE versions, the console isn't present until you first open it.\n // We build realMethod() replacements here that regenerate logging methods\n function enableLoggingWhenConsoleArrives(methodName) {\n return function () {\n if (typeof console !== undefinedType) {\n replaceLoggingMethods.call(this);\n this[methodName].apply(this, arguments);\n }\n };\n }\n\n // By default, we use closely bound real methods wherever possible, and\n // otherwise we wait for a console to appear, and then try again.\n function defaultMethodFactory(methodName, _level, _loggerName) {\n /*jshint validthis:true */\n return realMethod(methodName) ||\n enableLoggingWhenConsoleArrives.apply(this, arguments);\n }\n\n function Logger(name, factory) {\n // Private instance variables.\n var self = this;\n /**\n * The level inherited from a parent logger (or a global default). We\n * cache this here rather than delegating to the parent so that it stays\n * in sync with the actual logging methods that we have installed (the\n * parent could change levels but we might not have rebuilt the loggers\n * in this child yet).\n * @type {number}\n */\n var inheritedLevel;\n /**\n * The default level for this logger, if any. If set, this overrides\n * `inheritedLevel`.\n * @type {number|null}\n */\n var defaultLevel;\n /**\n * A user-specific level for this logger. If set, this overrides\n * `defaultLevel`.\n * @type {number|null}\n */\n var userLevel;\n\n var storageKey = \"loglevel\";\n if (typeof name === \"string\") {\n storageKey += \":\" + name;\n } else if (typeof name === \"symbol\") {\n storageKey = undefined;\n }\n\n function persistLevelIfPossible(levelNum) {\n var levelName = (logMethods[levelNum] || 'silent').toUpperCase();\n\n if (typeof window === undefinedType || !storageKey) return;\n\n // Use localStorage if available\n try {\n window.localStorage[storageKey] = levelName;\n return;\n } catch (ignore) {}\n\n // Use session cookie as fallback\n try {\n window.document.cookie =\n encodeURIComponent(storageKey) + \"=\" + levelName + \";\";\n } catch (ignore) {}\n }\n\n function getPersistedLevel() {\n var storedLevel;\n\n if (typeof window === undefinedType || !storageKey) return;\n\n try {\n storedLevel = window.localStorage[storageKey];\n } catch (ignore) {}\n\n // Fallback to cookies if local storage gives us nothing\n if (typeof storedLevel === undefinedType) {\n try {\n var cookie = window.document.cookie;\n var cookieName = encodeURIComponent(storageKey);\n var location = cookie.indexOf(cookieName + \"=\");\n if (location !== -1) {\n storedLevel = /^([^;]+)/.exec(\n cookie.slice(location + cookieName.length + 1)\n )[1];\n }\n } catch (ignore) {}\n }\n\n // If the stored level is not valid, treat it as if nothing was stored.\n if (self.levels[storedLevel] === undefined) {\n storedLevel = undefined;\n }\n\n return storedLevel;\n }\n\n function clearPersistedLevel() {\n if (typeof window === undefinedType || !storageKey) return;\n\n // Use localStorage if available\n try {\n window.localStorage.removeItem(storageKey);\n } catch (ignore) {}\n\n // Use session cookie as fallback\n try {\n window.document.cookie =\n encodeURIComponent(storageKey) + \"=; expires=Thu, 01 Jan 1970 00:00:00 UTC\";\n } catch (ignore) {}\n }\n\n function normalizeLevel(input) {\n var level = input;\n if (typeof level === \"string\" && self.levels[level.toUpperCase()] !== undefined) {\n level = self.levels[level.toUpperCase()];\n }\n if (typeof level === \"number\" && level >= 0 && level <= self.levels.SILENT) {\n return level;\n } else {\n throw new TypeError(\"log.setLevel() called with invalid level: \" + input);\n }\n }\n\n /*\n *\n * Public logger API - see https://github.com/pimterry/loglevel for details\n *\n */\n\n self.name = name;\n\n self.levels = { \"TRACE\": 0, \"DEBUG\": 1, \"INFO\": 2, \"WARN\": 3,\n \"ERROR\": 4, \"SILENT\": 5};\n\n self.methodFactory = factory || defaultMethodFactory;\n\n self.getLevel = function () {\n if (userLevel != null) {\n return userLevel;\n } else if (defaultLevel != null) {\n return defaultLevel;\n } else {\n return inheritedLevel;\n }\n };\n\n self.setLevel = function (level, persist) {\n userLevel = normalizeLevel(level);\n if (persist !== false) { // defaults to true\n persistLevelIfPossible(userLevel);\n }\n\n // NOTE: in v2, this should call rebuild(), which updates children.\n return replaceLoggingMethods.call(self);\n };\n\n self.setDefaultLevel = function (level) {\n defaultLevel = normalizeLevel(level);\n if (!getPersistedLevel()) {\n self.setLevel(level, false);\n }\n };\n\n self.resetLevel = function () {\n userLevel = null;\n clearPersistedLevel();\n replaceLoggingMethods.call(self);\n };\n\n self.enableAll = function(persist) {\n self.setLevel(self.levels.TRACE, persist);\n };\n\n self.disableAll = function(persist) {\n self.setLevel(self.levels.SILENT, persist);\n };\n\n self.rebuild = function () {\n if (defaultLogger !== self) {\n inheritedLevel = normalizeLevel(defaultLogger.getLevel());\n }\n replaceLoggingMethods.call(self);\n\n if (defaultLogger === self) {\n for (var childName in _loggersByName) {\n _loggersByName[childName].rebuild();\n }\n }\n };\n\n // Initialize all the internal levels.\n inheritedLevel = normalizeLevel(\n defaultLogger ? defaultLogger.getLevel() : \"WARN\"\n );\n var initialLevel = getPersistedLevel();\n if (initialLevel != null) {\n userLevel = normalizeLevel(initialLevel);\n }\n replaceLoggingMethods.call(self);\n }\n\n /*\n *\n * Top-level API\n *\n */\n\n defaultLogger = new Logger();\n\n defaultLogger.getLogger = function getLogger(name) {\n if ((typeof name !== \"symbol\" && typeof name !== \"string\") || name === \"\") {\n throw new TypeError(\"You must supply a name when creating a logger.\");\n }\n\n var logger = _loggersByName[name];\n if (!logger) {\n logger = _loggersByName[name] = new Logger(\n name,\n defaultLogger.methodFactory\n );\n }\n return logger;\n };\n\n // Grab the current global log variable in case of overwrite\n var _log = (typeof window !== undefinedType) ? window.log : undefined;\n defaultLogger.noConflict = function() {\n if (typeof window !== undefinedType &&\n window.log === defaultLogger) {\n window.log = _log;\n }\n\n return defaultLogger;\n };\n\n defaultLogger.getLoggers = function getLoggers() {\n return _loggersByName;\n };\n\n // ES6 default export, for compatibility\n defaultLogger['default'] = defaultLogger;\n\n return defaultLogger;\n}));\n"],"names":["root","definition","this","noop","isIE","window","navigator","test","userAgent","logMethods","_loggersByName","defaultLogger","bindMethod","obj","methodName","method","bind","Function","prototype","call","e","apply","arguments","traceForIE","console","log","trace","realMethod","undefined","replaceLoggingMethods","level","getLevel","i","length","methodFactory","name","debug","levels","SILENT","enableLoggingWhenConsoleArrives","defaultMethodFactory","_level","_loggerName","Logger","factory","inheritedLevel","defaultLevel","userLevel","self","storageKey","getPersistedLevel","storedLevel","localStorage","ignore","cookie","document","cookieName","encodeURIComponent","location","indexOf","exec","slice","normalizeLevel","input","toUpperCase","TypeError","setLevel","persist","levelNum","levelName","persistLevelIfPossible","setDefaultLevel","resetLevel","removeItem","clearPersistedLevel","enableAll","TRACE","disableAll","rebuild","childName","initialLevel","getLogger","logger","_log","noConflict","getLoggers","define","amd","module","exports"],"mappings":"AAkCC,IAAUA,KAAMC,WAAND,KASTE,OATeD,WAST,eAIAE,KAAO,aAEPC,KADgB,oBACDC,aADC,IACoCA,OAAOC,WAC3D,kBAAkBC,KAAKF,OAAOC,UAAUE,WAGxCC,WAAa,CACb,QACA,QACA,OACA,OACA,SAGAC,eAAiB,GACjBC,cAAgB,cAGXC,WAAWC,IAAKC,gBACjBC,OAASF,IAAIC,eACU,mBAAhBC,OAAOC,YACPD,OAAOC,KAAKH,gBAGRI,SAASC,UAAUF,KAAKG,KAAKJ,OAAQF,KAC9C,MAAOO,UAEE,kBACIH,SAASC,UAAUG,MAAMA,MAAMN,OAAQ,CAACF,IAAKS,uBAO3DC,aACDC,QAAQC,MACJD,QAAQC,IAAIJ,MACZG,QAAQC,IAAIJ,MAAMG,QAASF,WAG3BL,SAASC,UAAUG,MAAMA,MAAMG,QAAQC,IAAK,CAACD,QAASF,aAG1DE,QAAQE,OAAOF,QAAQE,iBAKtBC,WA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,eACpBA,eAAeqE,WAAWD,WAMpCjC,eAAiBiB,eACbnD,cAAgBA,cAAcoB,WAAa,YAE3CiD,aAAe9B,oBACC,MAAhB8B,eACAjC,UAAYe,eAAekB,eAE/BnD,sBAAsBV,KAAK6B,OAS7BrC,cAAgB,IAAIgC,QAENsC,UAAY,SAAmB9C,SACpB,iBAATA,MAAqC,iBAATA,MAA+B,KAATA,WACpD,IAAI8B,UAAU,sDAGpBiB,OAASxE,eAAeyB,aACvB+C,SACDA,OAASxE,eAAeyB,MAAQ,IAAIQ,OAChCR,KACAxB,cAAcuB,gBAGfgD,YAIPC,KA9TgB,oBA8TD9E,OAA4BA,OAAOoB,SAAMG,SAC5DjB,cAAcyE,WAAa,iBA/TP,oBAgUL/E,QACJA,OAAOoB,MAAQd,gBAClBN,OAAOoB,IAAM0D,MAGVxE,eAGXA,cAAc0E,WAAa,kBAChB3E,gBAIXC,cAAa,QAAcA,cAEpBA,eA3Ve,mBAAX2E,QAAyBA,OAAOC,IACvCD,uBAAOrF,YACkB,iBAAXuF,QAAuBA,OAAOC,QAC5CD,OAAOC,QAAUxF,aAEjBD,KAAKyB,IAAMxB"} \ No newline at end of file diff --git a/lib/amd/src/loglevel.js b/lib/amd/src/loglevel.js index dbdc8095b8a..a375d4f3eaf 100644 --- a/lib/amd/src/loglevel.js +++ b/lib/amd/src/loglevel.js @@ -26,7 +26,12 @@ // Copy loglevel.js into lib/amd/src/ in Moodle folder. // Add the license as a comment to the file and these instructions. -/*! loglevel - v1.8.1 - https://github.com/pimterry/loglevel - (c) 2022 Tim Perry - licensed MIT */ +/* +* loglevel - https://github.com/pimterry/loglevel +* +* Copyright (c) 2013 Tim Perry +* Licensed under the MIT license. +*/ (function (root, definition) { "use strict"; if (typeof define === 'function' && define.amd) { @@ -54,6 +59,9 @@ "error" ]; + var _loggersByName = {}; + var defaultLogger = null; + // Cross-browser bind equivalent that works at least back to IE6 function bindMethod(obj, methodName) { var method = obj[methodName]; @@ -106,25 +114,33 @@ // These private functions always need `this` to be set properly - function replaceLoggingMethods(level, loggerName) { + function replaceLoggingMethods() { /*jshint validthis:true */ + var level = this.getLevel(); + + // Replace the actual methods. for (var i = 0; i < logMethods.length; i++) { var methodName = logMethods[i]; this[methodName] = (i < level) ? noop : - this.methodFactory(methodName, level, loggerName); + this.methodFactory(methodName, level, this.name); } // Define log.log as an alias for log.debug this.log = this.debug; + + // Return any important warnings. + if (typeof console === undefinedType && level < this.levels.SILENT) { + return "No console available for logging"; + } } // In old IE versions, the console isn't present until you first open it. // We build realMethod() replacements here that regenerate logging methods - function enableLoggingWhenConsoleArrives(methodName, level, loggerName) { + function enableLoggingWhenConsoleArrives(methodName) { return function () { if (typeof console !== undefinedType) { - replaceLoggingMethods.call(this, level, loggerName); + replaceLoggingMethods.call(this); this[methodName].apply(this, arguments); } }; @@ -132,16 +148,36 @@ // By default, we use closely bound real methods wherever possible, and // otherwise we wait for a console to appear, and then try again. - function defaultMethodFactory(methodName, level, loggerName) { + function defaultMethodFactory(methodName, _level, _loggerName) { /*jshint validthis:true */ return realMethod(methodName) || enableLoggingWhenConsoleArrives.apply(this, arguments); } - function Logger(name, defaultLevel, factory) { + function Logger(name, factory) { + // Private instance variables. var self = this; - var currentLevel; - defaultLevel = defaultLevel == null ? "WARN" : defaultLevel; + /** + * The level inherited from a parent logger (or a global default). We + * cache this here rather than delegating to the parent so that it stays + * in sync with the actual logging methods that we have installed (the + * parent could change levels but we might not have rebuilt the loggers + * in this child yet). + * @type {number} + */ + var inheritedLevel; + /** + * The default level for this logger, if any. If set, this overrides + * `inheritedLevel`. + * @type {number|null} + */ + var defaultLevel; + /** + * A user-specific level for this logger. If set, this overrides + * `defaultLevel`. + * @type {number|null} + */ + var userLevel; var storageKey = "loglevel"; if (typeof name === "string") { @@ -181,10 +217,12 @@ if (typeof storedLevel === undefinedType) { try { var cookie = window.document.cookie; - var location = cookie.indexOf( - encodeURIComponent(storageKey) + "="); + var cookieName = encodeURIComponent(storageKey); + var location = cookie.indexOf(cookieName + "="); if (location !== -1) { - storedLevel = /^([^;]+)/.exec(cookie.slice(location))[1]; + storedLevel = /^([^;]+)/.exec( + cookie.slice(location + cookieName.length + 1) + )[1]; } } catch (ignore) {} } @@ -203,7 +241,6 @@ // Use localStorage if available try { window.localStorage.removeItem(storageKey); - return; } catch (ignore) {} // Use session cookie as fallback @@ -213,6 +250,18 @@ } catch (ignore) {} } + function normalizeLevel(input) { + var level = input; + if (typeof level === "string" && self.levels[level.toUpperCase()] !== undefined) { + level = self.levels[level.toUpperCase()]; + } + if (typeof level === "number" && level >= 0 && level <= self.levels.SILENT) { + return level; + } else { + throw new TypeError("log.setLevel() called with invalid level: " + input); + } + } + /* * * Public logger API - see https://github.com/pimterry/loglevel for details @@ -227,37 +276,36 @@ self.methodFactory = factory || defaultMethodFactory; self.getLevel = function () { - return currentLevel; + if (userLevel != null) { + return userLevel; + } else if (defaultLevel != null) { + return defaultLevel; + } else { + return inheritedLevel; + } }; self.setLevel = function (level, persist) { - if (typeof level === "string" && self.levels[level.toUpperCase()] !== undefined) { - level = self.levels[level.toUpperCase()]; - } - if (typeof level === "number" && level >= 0 && level <= self.levels.SILENT) { - currentLevel = level; - if (persist !== false) { // defaults to true - persistLevelIfPossible(level); - } - replaceLoggingMethods.call(self, level, name); - if (typeof console === undefinedType && level < self.levels.SILENT) { - return "No console available for logging"; - } - } else { - throw "log.setLevel() called with invalid level: " + level; + userLevel = normalizeLevel(level); + if (persist !== false) { // defaults to true + persistLevelIfPossible(userLevel); } + + // NOTE: in v2, this should call rebuild(), which updates children. + return replaceLoggingMethods.call(self); }; self.setDefaultLevel = function (level) { - defaultLevel = level; + defaultLevel = normalizeLevel(level); if (!getPersistedLevel()) { self.setLevel(level, false); } }; self.resetLevel = function () { - self.setLevel(defaultLevel, false); + userLevel = null; clearPersistedLevel(); + replaceLoggingMethods.call(self); }; self.enableAll = function(persist) { @@ -268,12 +316,28 @@ self.setLevel(self.levels.SILENT, persist); }; - // Initialize with the right level + self.rebuild = function () { + if (defaultLogger !== self) { + inheritedLevel = normalizeLevel(defaultLogger.getLevel()); + } + replaceLoggingMethods.call(self); + + if (defaultLogger === self) { + for (var childName in _loggersByName) { + _loggersByName[childName].rebuild(); + } + } + }; + + // Initialize all the internal levels. + inheritedLevel = normalizeLevel( + defaultLogger ? defaultLogger.getLevel() : "WARN" + ); var initialLevel = getPersistedLevel(); - if (initialLevel == null) { - initialLevel = defaultLevel; + if (initialLevel != null) { + userLevel = normalizeLevel(initialLevel); } - self.setLevel(initialLevel, false); + replaceLoggingMethods.call(self); } /* @@ -282,18 +346,19 @@ * */ - var defaultLogger = new Logger(); + defaultLogger = new Logger(); - var _loggersByName = {}; defaultLogger.getLogger = function getLogger(name) { if ((typeof name !== "symbol" && typeof name !== "string") || name === "") { - throw new TypeError("You must supply a name when creating a logger."); + throw new TypeError("You must supply a name when creating a logger."); } var logger = _loggersByName[name]; if (!logger) { - logger = _loggersByName[name] = new Logger( - name, defaultLogger.getLevel(), defaultLogger.methodFactory); + logger = _loggersByName[name] = new Logger( + name, + defaultLogger.methodFactory + ); } return logger; }; diff --git a/lib/thirdpartylibs.xml b/lib/thirdpartylibs.xml index d59a4ddc9e0..3dda3cfad47 100644 --- a/lib/thirdpartylibs.xml +++ b/lib/thirdpartylibs.xml @@ -285,7 +285,7 @@ All rights reserved. amd/src/loglevel.js loglevel.js Minimal lightweight simple logging for JavaScript. - 1.8.1 + 1.9.1 MIT https://github.com/pimterry/loglevel/