stringify did-fail-load error

directly preload front-logger
simplify front-logger
This commit is contained in:
Araxeus
2021-05-04 01:22:47 +03:00
parent 8f766bcbaa
commit d5b9e3c960
3 changed files with 7 additions and 10 deletions

View File

@ -168,7 +168,7 @@ app.once("browser-window-created", (event, win) => {
frameProcessId,
frameRoutingId,
) => {
const log = {
const log = JSON.stringify({
error: "did-fail-load",
event,
errorCode,
@ -177,9 +177,9 @@ app.once("browser-window-created", (event, win) => {
isMainFrame,
frameProcessId,
frameRoutingId,
};
}, null, "\t");
if (is.dev()) {
console.log(log.toString());
console.log(log);
}
win.webContents.send("log", log);
win.webContents.loadFile(path.join(__dirname, "error.html"));

View File

@ -34,8 +34,7 @@ document.addEventListener("DOMContentLoaded", () => {
fileExists(songInfoProviderPath, require(songInfoProviderPath));
// inject front logger
const loggerPath = path.join(__dirname, "providers", "front-logger.js")
fileExists(loggerPath, require(loggerPath));
require("./providers/front-logger")();
// Add action for reloading
global.reload = () =>

View File

@ -1,11 +1,9 @@
const { ipcRenderer } = require("electron");
function logToString(log) {
let string = (typeof log === "string") ? log : log.toString();
if (!string || string.includes("[object Object]")) {
string = JSON.stringify(log, null, "\t");
}
return string;
return (typeof log === "string") ?
log :
JSON.stringify(log, null, "\t");
}
module.exports = () => {