[MM-51873] Create central logging module for adding prefixes to differentiate logs between modules (#2652)
* Create central logging module for adding prefixes to differentiate logs between modules * Turn logger into class * Merge'd * Rework to use class more intelligently * Fix modalView * Fix webContentEvents * Update src/main/app/intercom.ts Co-authored-by: Daniel Espino García <larkox@gmail.com> * Shorten prefixes on object creation --------- Co-authored-by: Daniel Espino García <larkox@gmail.com>
This commit is contained in:
@@ -2,8 +2,6 @@
|
||||
// See LICENSE.txt for license information.
|
||||
import {BrowserView, ipcMain, IpcMainEvent} from 'electron';
|
||||
|
||||
import log from 'electron-log';
|
||||
|
||||
import {CombinedConfig} from 'types/config';
|
||||
import {CoordinatesToJsonType, DownloadedItem, DownloadsMenuOpenEventPayload} from 'types/downloads';
|
||||
|
||||
@@ -20,6 +18,7 @@ import {
|
||||
UPDATE_DOWNLOADS_DROPDOWN_MENU,
|
||||
UPDATE_DOWNLOADS_DROPDOWN_MENU_ITEM,
|
||||
} from 'common/communication';
|
||||
import {Logger} from 'common/log';
|
||||
import {
|
||||
DOWNLOADS_DROPDOWN_FULL_WIDTH,
|
||||
DOWNLOADS_DROPDOWN_MENU_FULL_HEIGHT,
|
||||
@@ -32,6 +31,8 @@ import WindowManager from '../windows/windowManager';
|
||||
import downloadsManager from 'main/downloadsManager';
|
||||
import MainWindow from 'main/windows/mainWindow';
|
||||
|
||||
const log = new Logger('DownloadsDropdownMenuView');
|
||||
|
||||
export default class DownloadsDropdownMenuView {
|
||||
open: boolean;
|
||||
view: BrowserView;
|
||||
@@ -81,7 +82,7 @@ export default class DownloadsDropdownMenuView {
|
||||
}
|
||||
|
||||
updateItem = (event: IpcMainEvent, item: DownloadedItem) => {
|
||||
log.debug('DownloadsDropdownMenuView.updateItem', {item});
|
||||
log.debug('updateItem', {item});
|
||||
|
||||
this.item = item;
|
||||
|
||||
@@ -89,7 +90,7 @@ export default class DownloadsDropdownMenuView {
|
||||
}
|
||||
|
||||
updateConfig = (event: IpcMainEvent, config: CombinedConfig) => {
|
||||
log.debug('DownloadsDropdownMenuView.updateConfig');
|
||||
log.debug('updateConfig');
|
||||
|
||||
this.darkMode = config.darkMode;
|
||||
this.updateDownloadsDropdownMenu();
|
||||
@@ -100,7 +101,7 @@ export default class DownloadsDropdownMenuView {
|
||||
* the downloads dropdown at the correct position
|
||||
*/
|
||||
updateWindowBounds = () => {
|
||||
log.debug('DownloadsDropdownMenuView.updateWindowBounds');
|
||||
log.debug('updateWindowBounds');
|
||||
|
||||
const mainWindow = MainWindow.get();
|
||||
if (mainWindow) {
|
||||
@@ -111,7 +112,7 @@ export default class DownloadsDropdownMenuView {
|
||||
}
|
||||
|
||||
updateDownloadsDropdownMenu = () => {
|
||||
log.debug('DownloadsDropdownMenuView.updateDownloadsDropdownMenu');
|
||||
log.debug('updateDownloadsDropdownMenu');
|
||||
|
||||
this.view.webContents.send(
|
||||
UPDATE_DOWNLOADS_DROPDOWN_MENU,
|
||||
@@ -123,7 +124,7 @@ export default class DownloadsDropdownMenuView {
|
||||
}
|
||||
|
||||
handleOpen = (event: IpcMainEvent, payload: DownloadsMenuOpenEventPayload = {} as DownloadsMenuOpenEventPayload) => {
|
||||
log.debug('DownloadsDropdownMenuView.handleOpen', {bounds: this.bounds, payload});
|
||||
log.debug('handleOpen', {bounds: this.bounds, payload});
|
||||
|
||||
if (!this.bounds) {
|
||||
return;
|
||||
@@ -131,7 +132,7 @@ export default class DownloadsDropdownMenuView {
|
||||
|
||||
const {item, coordinates} = payload;
|
||||
|
||||
log.debug('DownloadsDropdownMenuView.handleOpen', {item, coordinates});
|
||||
log.debug('handleOpen', {item, coordinates});
|
||||
|
||||
this.open = true;
|
||||
this.coordinates = coordinates;
|
||||
@@ -144,7 +145,7 @@ export default class DownloadsDropdownMenuView {
|
||||
}
|
||||
|
||||
handleClose = () => {
|
||||
log.debug('DownloadsDropdownMenuView.handleClose');
|
||||
log.debug('handleClose');
|
||||
|
||||
this.open = false;
|
||||
this.item = undefined;
|
||||
|
Reference in New Issue
Block a user