[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,12 +2,12 @@
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {app, dialog, IpcMainEvent, IpcMainInvokeEvent, Menu} from 'electron';
|
||||
import log from 'electron-log';
|
||||
|
||||
import {Team, TeamWithIndex} from 'types/config';
|
||||
import {MentionData} from 'types/notification';
|
||||
|
||||
import Config from 'common/config';
|
||||
import {Logger} from 'common/log';
|
||||
import {getDefaultTeamWithTabsFromTeam} from 'common/tabs/TabView';
|
||||
import {ping} from 'common/utils/requests';
|
||||
|
||||
@@ -20,8 +20,10 @@ import MainWindow from 'main/windows/mainWindow';
|
||||
import {handleAppBeforeQuit} from './app';
|
||||
import {updateServerInfos} from './utils';
|
||||
|
||||
const log = new Logger('App.Intercom');
|
||||
|
||||
export function handleReloadConfig() {
|
||||
log.debug('Intercom.handleReloadConfig');
|
||||
log.debug('handleReloadConfig');
|
||||
|
||||
Config.reload();
|
||||
WindowManager.handleUpdateConfig();
|
||||
@@ -42,17 +44,17 @@ export function handleQuit(e: IpcMainEvent, reason: string, stack: string) {
|
||||
}
|
||||
|
||||
export function handleSwitchServer(event: IpcMainEvent, serverName: string) {
|
||||
log.silly('Intercom.handleSwitchServer', serverName);
|
||||
log.silly('handleSwitchServer', serverName);
|
||||
WindowManager.switchServer(serverName);
|
||||
}
|
||||
|
||||
export function handleSwitchTab(event: IpcMainEvent, serverName: string, tabName: string) {
|
||||
log.silly('Intercom.handleSwitchTab', {serverName, tabName});
|
||||
log.silly('handleSwitchTab', {serverName, tabName});
|
||||
WindowManager.switchTab(serverName, tabName);
|
||||
}
|
||||
|
||||
export function handleCloseTab(event: IpcMainEvent, serverName: string, tabName: string) {
|
||||
log.debug('Intercom.handleCloseTab', {serverName, tabName});
|
||||
log.debug('handleCloseTab', {serverName, tabName});
|
||||
|
||||
const teams = Config.teams;
|
||||
teams.forEach((team) => {
|
||||
@@ -70,7 +72,7 @@ export function handleCloseTab(event: IpcMainEvent, serverName: string, tabName:
|
||||
}
|
||||
|
||||
export function handleOpenTab(event: IpcMainEvent, serverName: string, tabName: string) {
|
||||
log.debug('Intercom.handleOpenTab', {serverName, tabName});
|
||||
log.debug('handleOpenTab', {serverName, tabName});
|
||||
|
||||
const teams = Config.teams;
|
||||
teams.forEach((team) => {
|
||||
@@ -87,7 +89,7 @@ export function handleOpenTab(event: IpcMainEvent, serverName: string, tabName:
|
||||
}
|
||||
|
||||
export function handleShowOnboardingScreens(showWelcomeScreen: boolean, showNewServerModal: boolean, mainWindowIsVisible: boolean) {
|
||||
log.debug('Intercom.handleShowOnboardingScreens', {showWelcomeScreen, showNewServerModal, mainWindowIsVisible});
|
||||
log.debug('handleShowOnboardingScreens', {showWelcomeScreen, showNewServerModal, mainWindowIsVisible});
|
||||
|
||||
if (showWelcomeScreen) {
|
||||
handleWelcomeScreenModal();
|
||||
@@ -124,7 +126,7 @@ export function handleMainWindowIsShown() {
|
||||
|
||||
const mainWindow = MainWindow.get();
|
||||
|
||||
log.debug('intercom.handleMainWindowIsShown', {configTeams: Config.teams, showWelcomeScreen, showNewServerModal, mainWindow: Boolean(mainWindow)});
|
||||
log.debug('handleMainWindowIsShown', {configTeams: Config.teams, showWelcomeScreen, showNewServerModal, mainWindow: Boolean(mainWindow)});
|
||||
if (mainWindow?.isVisible()) {
|
||||
handleShowOnboardingScreens(showWelcomeScreen(), showNewServerModal(), true);
|
||||
} else {
|
||||
@@ -135,7 +137,7 @@ export function handleMainWindowIsShown() {
|
||||
}
|
||||
|
||||
export function handleNewServerModal() {
|
||||
log.debug('Intercom.handleNewServerModal');
|
||||
log.debug('handleNewServerModal');
|
||||
|
||||
const html = getLocalURLString('newServer.html');
|
||||
|
||||
@@ -167,7 +169,7 @@ export function handleNewServerModal() {
|
||||
}
|
||||
|
||||
export function handleEditServerModal(e: IpcMainEvent, name: string) {
|
||||
log.debug('Intercom.handleEditServerModal', name);
|
||||
log.debug('handleEditServerModal', name);
|
||||
|
||||
const html = getLocalURLString('editServer.html');
|
||||
|
||||
@@ -209,7 +211,7 @@ export function handleEditServerModal(e: IpcMainEvent, name: string) {
|
||||
}
|
||||
|
||||
export function handleRemoveServerModal(e: IpcMainEvent, name: string) {
|
||||
log.debug('Intercom.handleRemoveServerModal', name);
|
||||
log.debug('handleRemoveServerModal', name);
|
||||
|
||||
const html = getLocalURLString('removeServer.html');
|
||||
|
||||
@@ -249,7 +251,7 @@ export function handleRemoveServerModal(e: IpcMainEvent, name: string) {
|
||||
}
|
||||
|
||||
export function handleWelcomeScreenModal() {
|
||||
log.debug('Intercom.handleWelcomeScreenModal');
|
||||
log.debug('handleWelcomeScreenModal');
|
||||
|
||||
const html = getLocalURLString('welcomeScreen.html');
|
||||
|
||||
@@ -281,12 +283,12 @@ export function handleWelcomeScreenModal() {
|
||||
}
|
||||
|
||||
export function handleMentionNotification(event: IpcMainEvent, title: string, body: string, channel: {id: string}, teamId: string, url: string, silent: boolean, data: MentionData) {
|
||||
log.debug('Intercom.handleMentionNotification', {title, body, channel, teamId, url, silent, data});
|
||||
log.debug('handleMentionNotification', {title, body, channel, teamId, url, silent, data});
|
||||
displayMention(title, body, channel, teamId, url, silent, event.sender, data);
|
||||
}
|
||||
|
||||
export function handleOpenAppMenu() {
|
||||
log.debug('Intercom.handleOpenAppMenu');
|
||||
log.debug('handleOpenAppMenu');
|
||||
|
||||
const windowMenu = Menu.getApplicationMenu();
|
||||
if (!windowMenu) {
|
||||
@@ -301,7 +303,7 @@ export function handleOpenAppMenu() {
|
||||
}
|
||||
|
||||
export async function handleSelectDownload(event: IpcMainInvokeEvent, startFrom: string) {
|
||||
log.debug('Intercom.handleSelectDownload', startFrom);
|
||||
log.debug('handleSelectDownload', startFrom);
|
||||
|
||||
const message = 'Specify the folder where files will download';
|
||||
const result = await dialog.showOpenDialog({defaultPath: startFrom || Config.downloadLocation,
|
||||
@@ -312,7 +314,7 @@ export async function handleSelectDownload(event: IpcMainInvokeEvent, startFrom:
|
||||
}
|
||||
|
||||
export function handleUpdateLastActive(event: IpcMainEvent, serverName: string, viewName: string) {
|
||||
log.debug('Intercom.handleUpdateLastActive', {serverName, viewName});
|
||||
log.debug('handleUpdateLastActive', {serverName, viewName});
|
||||
|
||||
const teams = Config.teams;
|
||||
teams.forEach((team) => {
|
||||
|
Reference in New Issue
Block a user