refactor: cleanup log codes
This commit is contained in:
1 parent
89f68ce61c
commit
df48a423af
3 files changed
+10
-2
No files matched your search
@@ -7,6 +7,7 @@ import {
|
||||
import Constants, { TrayOptions } from './utils/Constants'
|
||||
import IPCs from './IPCs'
|
||||
import { createTray, hideWindow, showWindow } from './tray'
|
||||
import log from 'electron-log/main'
|
||||
|
||||
const options = {
|
||||
width: Constants.IS_DEV_ENV ? 1500 : 1200,
|
||||
@@ -28,6 +29,8 @@ const exitApp = (mainWindow: BrowserWindow): void => {
|
||||
}
|
||||
|
||||
export const createMainWindow = async (): Promise<BrowserWindow> => {
|
||||
log.silly('Creating new window...')
|
||||
|
||||
let opt: BrowserWindowConstructorOptions = {
|
||||
title: Constants.APP_NAME,
|
||||
show: false,
|
||||
|
||||
@@ -16,6 +16,8 @@ const initializeMainLogger = () => {
|
||||
log.transports.file.format = '[{y}{m}{d} {h}:{i}:{s}.{ms}|{level}]{text}'
|
||||
log.transports.console.format = '{h}:{i}:{s}.{ms} {text}'
|
||||
log.transports.console.level = 'silly'
|
||||
|
||||
log.silly('App is ready')
|
||||
}
|
||||
|
||||
app.on('ready', async () => {
|
||||
|
||||
@@ -18,7 +18,7 @@ contextBridge.exposeInMainWorld('mainApi', {
|
||||
if (mainAvailChannels.includes(channel)) {
|
||||
ipcRenderer.send.apply(null, [channel, ...data])
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
console.log({ type: 'send', channel, request: data })
|
||||
log.silly(`[IPC_SEND::${channel}]`, { request: data })
|
||||
}
|
||||
} else {
|
||||
throw new Error(`Unknown ipc channel name: ${channel}`)
|
||||
@@ -58,7 +58,10 @@ contextBridge.exposeInMainWorld('mainApi', {
|
||||
if (mainAvailChannels.includes(channel)) {
|
||||
const result = await ipcRenderer.invoke.apply(null, [channel, ...data])
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
console.log({ type: 'invoke', channel, request: data, result })
|
||||
log.silly(`[IPC_INVOKE::${channel}]`, {
|
||||
request: data,
|
||||
result
|
||||
})
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user