[General] Make log global, remove unused generic stub

pull/2/head
Oj 2 years ago
parent b4bcd82054
commit bcc5a2837d

1
src/bootstrap.js vendored

@ -2,7 +2,6 @@ const { join } = require('path');
const NodeModule = require('module');
const { app } = require('electron');
const log = require('./utils/log');
const requireNative = require('./utils/requireNative');
const paths = require('./paths');
const buildInfo = require('./utils/buildInfo');

@ -1,7 +1,5 @@
const { app } = require("electron");
const log = require('./utils/log');
exports.init = () => {
/* process.on('uncaughtException', error => {
const stack = error.stack ? error.stack : String(error);

@ -1,4 +1,5 @@
const log = require('./utils/log');
global.log = log; // Make log global for easy usage everywhere
log('', 'Initing...');

@ -1,7 +1,6 @@
const { join, dirname, basename } = require('path');
const { app } = require('electron');
const log = require('./utils/log');
const buildInfo = require('./utils/buildInfo');

@ -67,6 +67,8 @@ const events = new _events.EventEmitter();
exports.events = events;
function webContentsSend(win, event, ...args) {
log('Splash', `Sending to webcontents:`, event, args);
if (win != null && win.webContents != null) {
win.webContents.send(`DISCORD_${event}`, ...args);
}
@ -299,6 +301,8 @@ function initOldUpdater() {
}
function initSplash(startMinimized = false) {
log('Splash', `Initing splash`);
splashState = {};
launchedMainWindow = false;
updateAttempt = 0;
@ -315,6 +319,8 @@ function initSplash(startMinimized = false) {
}
function destroySplash() {
log('Splash', `Destroying splash`);
stopUpdateTimeout();
if (splashWindow) {
@ -385,6 +391,7 @@ function launchSplashWindow(startMinimized) {
}
};
splashWindow = new _electron.BrowserWindow(windowConfig); // prevent users from dropping links to navigate in splash window
log('Splash', 'Created BrowserWindow');
splashWindow.webContents.on('will-navigate', e => e.preventDefault());
splashWindow.webContents.on('new-window', (e, windowURL) => {
@ -408,6 +415,8 @@ function launchSplashWindow(startMinimized) {
}
_ipcMain.default.on('SPLASH_SCREEN_READY', () => {
log('Splash', 'Window declared ready, showing and starting update process');
const cachedQuote = chooseCachedQuote();
if (cachedQuote) {
@ -436,6 +445,8 @@ function launchSplashWindow(startMinimized) {
});
splashWindow.loadURL(splashUrl);
log('Splash', `Loading window (with url ${splashUrl})`);
}
function launchMainWindow() {
@ -456,12 +467,16 @@ function scheduleUpdateCheck() {
}
function focusWindow() {
log('Splash', `Told to focus splash window`);
if (splashWindow != null) {
splashWindow.focus();
}
}
function pageReady() {
log('Splash', `Page ready called, destroying splash and marking app to show`);
destroySplash();
process.nextTick(() => events.emit(APP_SHOULD_SHOW));
}

@ -155,6 +155,8 @@ async function electronRequest({
}
async function requestWithMethod(method, options) {
log('Request', method, options);
if (typeof options === 'string') {
options = {
url: options

@ -1,8 +1,6 @@
const { readFileSync, statSync, writeFileSync } = require('fs');
const { join } = require('path');
const log = require('./log');
class Settings { // Heavily based on original for compat, but simplified and tweaked
constructor(root) {
this.path = join(root, 'settings.json');

@ -1,13 +0,0 @@
const log = require('./log');
module.exports = (debugName) => {
return new Proxy({}, {
get(target, prop, receiver) {
log('Stub', `${debugName}: Tried getting ${prop}`);
},
set(target, prop, value, receiver) {
log('Stub', `${debugName}: Tried setting ${prop}, ${value}`);
}
});
};
Loading…
Cancel
Save