1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2024-12-22 04:40:20 +01:00

Simplified relation logging <-> settings

For #166
This commit is contained in:
kkapsner 2018-09-15 21:13:25 +02:00
parent 9d5e8b71ed
commit 57ef8a4166
7 changed files with 19 additions and 27 deletions

View File

@ -8,9 +8,9 @@
<body>
<div id="actions"></div>
<script src="../lib/require.js"></script>
<script src="../lib/logging.js"></script>
<script src="../lib/settingDefinitions.js"></script>
<script src="../lib/settings.js"></script>
<script src="../lib/logging.js"></script>
<script src="browserAction.js"></script>
</body>
</html>

View File

@ -16,7 +16,11 @@
scope = window.scope.logging;
}
const settings = require("./settings");
let settings = false;
require.on("./settings", function(realSettings){
settings = realSettings;
settings.loaded.then(scope.clearQueue);
});
var prefix = "";
@ -39,7 +43,7 @@
if (!date){
date = new Date();
}
if (settings.isStillDefault || queue.length){
if (!settings || !settings.isInitialized() || queue.length){
queue.push({level, args, date});
}
else {
@ -96,7 +100,6 @@
metaLog("logging queue cleared");
}
};
settings.loaded.then(scope.clearQueue);
scope.error = error;
scope.warning = warning;
scope.message = message;

View File

@ -13,23 +13,7 @@
window.scope.settings = scope;
}
var logging = {};
(function(){
var loggingQueue = [];
require.on("./logging", function(realLogging){
logging = realLogging;
loggingQueue.forEach(function(logEntry){
logging[logEntry.name](...logEntry.args, logEntry.date);
});
loggingQueue = [];
});
["error", "warning", "message", "notice", "verbose"].forEach(function(name){
logging[name] = function(...args){
loggingQueue.push({name, args, date: new Date()});
};
});
}());
const logging = require("./logging");
const settingDefinitions = require("./settingDefinitions.js");
const definitionsByName = {};
const defaultSymbol = "";
@ -568,6 +552,9 @@
logging.verbose("loading settings");
let initialized = false;
scope.isInitialized = function(){
return initialized;
};
const initEvents = [];
scope.init = function(storage){
if (initialized){
@ -631,4 +618,6 @@
});
};
Object.seal(scope);
require.emit("./settings");
}());

View File

@ -10,10 +10,10 @@
"background": {
"scripts": [
"lib/require.js",
"lib/logging.js",
"lib/settingDefinitions.js",
"lib/settingsMigration.js",
"lib/settings.js",
"lib/logging.js",
"lib/lists.js",
"lib/persistentRndStorage.js",
"lib/dataUrls.js",
@ -28,11 +28,11 @@
"run_at": "document_start",
"js": [
"lib/require.js",
"lib/logging.js",
"lib/settingDefinitions.js",
"lib/settings.js",
"lib/logging.js",
"lib/colorStatistics.js",
"lib/webgl.js",
"lib/hash.js",

View File

@ -8,9 +8,9 @@
<body>
<textarea id="settings"></textarea>
<script src="../lib/require.js"></script>
<script src="../lib/logging.js"></script>
<script src="../lib/settingDefinitions.js"></script>
<script src="../lib/settings.js"></script>
<script src="../lib/logging.js"></script>
<script src="export.js"></script>
</body>
</html>

View File

@ -7,9 +7,9 @@
</head>
<body>
<script src="../lib/require.js"></script>
<script src="../lib/logging.js"></script>
<script src="../lib/settingDefinitions.js"></script>
<script src="../lib/settings.js"></script>
<script src="../lib/logging.js"></script>
<script src="optionsGui.js"></script>
<script src="settingsDisplay.js"></script>
<script src="options.js"></script>

View File

@ -11,9 +11,9 @@
<li>...</li>
</ul>
<script src="../lib/require.js"></script>
<script src="../lib/logging.js"></script>
<script src="../lib/settingDefinitions.js"></script>
<script src="../lib/settings.js"></script>
<script src="../lib/logging.js"></script>
<script src="../lib/lists.js"></script>
<script src="../lib/callingStack.js"></script>
<script src="gui.js"></script>