-/*! loglevel - v1.7.1 - https://github.com/pimterry/loglevel - (c) 2020 Tim Perry - licensed MIT */
+/*! loglevel - v1.8.0 - https://github.com/pimterry/loglevel - (c) 2021 Tim Perry - licensed MIT */
(function (root, definition) {
"use strict";
if (typeof define === 'function' && define.amd) {
function Logger(name, defaultLevel, factory) {
var self = this;
var currentLevel;
+ defaultLevel = defaultLevel == null ? "WARN" : defaultLevel;
var storageKey = "loglevel";
if (typeof name === "string") {
return storedLevel;
}
+ function clearPersistedLevel() {
+ if (typeof window === undefinedType || !storageKey) return;
+
+ // Use localStorage if available
+ try {
+ window.localStorage.removeItem(storageKey);
+ return;
+ } catch (ignore) {}
+
+ // Use session cookie as fallback
+ try {
+ window.document.cookie =
+ encodeURIComponent(storageKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
+ } catch (ignore) {}
+ }
+
/*
*
* Public logger API - see https://github.com/pimterry/loglevel for details
};
self.setDefaultLevel = function (level) {
+ defaultLevel = level;
if (!getPersistedLevel()) {
self.setLevel(level, false);
}
};
+ self.resetLevel = function () {
+ self.setLevel(defaultLevel, false);
+ clearPersistedLevel();
+ };
+
self.enableAll = function(persist) {
self.setLevel(self.levels.TRACE, persist);
};
// Initialize with the right level
var initialLevel = getPersistedLevel();
if (initialLevel == null) {
- initialLevel = defaultLevel == null ? "WARN" : defaultLevel;
+ initialLevel = defaultLevel;
}
self.setLevel(initialLevel, false);
}