Reviewed Input and Output Waiters and improved logging in workers

This commit is contained in:
n1474335 2023-01-18 18:07:06 +00:00
parent 56d1a016da
commit 91f1be8c70
12 changed files with 204 additions and 111 deletions

View file

@ -7,11 +7,17 @@
*/
import Dish from "../../core/Dish.mjs";
import loglevelMessagePrefix from "loglevel-message-prefix";
loglevelMessagePrefix(log, {
prefixes: [],
staticPrefixes: ["DishWorker"]
});
self.addEventListener("message", function(e) {
// Handle message from the main thread
const r = e.data;
log.debug(`DishWorker receiving command '${r.action}'`);
log.debug(`Receiving command '${r.action}'`);
switch (r.action) {
case "getDishAs":
@ -20,8 +26,11 @@ self.addEventListener("message", function(e) {
case "getDishTitle":
getDishTitle(r.data);
break;
case "setLogLevel":
log.setLevel(r.data, false);
break;
default:
log.error(`DishWorker sent invalid action: '${r.action}'`);
log.error(`Unknown action: '${r.action}'`);
}
});