perf: 支持日志文件
parent
83276a328f
commit
a4ce3fd138
|
@ -16,6 +16,7 @@
|
|||
"start": "node ./start"
|
||||
},
|
||||
"dependencies": {
|
||||
"log4js": "^6.3.0",
|
||||
"@docmirror/mitmproxy": "^1.1.0",
|
||||
"agentkeepalive": "^2.1.1",
|
||||
"charset": "^1.0.0",
|
||||
|
|
|
@ -6,12 +6,14 @@ const modules = require('./modules')
|
|||
const lodash = require('lodash')
|
||||
const proxyServer = require('@docmirror/mitmproxy')
|
||||
const proxyConfig = proxyServer.config
|
||||
const log = require('./utils/util.log')
|
||||
const context = {
|
||||
config,
|
||||
shell,
|
||||
status,
|
||||
event,
|
||||
rootCaFile: proxyConfig.getDefaultCACertPath()
|
||||
rootCaFile: proxyConfig.getDefaultCACertPath(),
|
||||
log
|
||||
}
|
||||
|
||||
function setupPlugin (key, plugin, context, config) {
|
||||
|
@ -43,14 +45,14 @@ module.exports = {
|
|||
try {
|
||||
await server.start({ mitmproxyPath })
|
||||
} catch (err) {
|
||||
console.error('代理服务启动失败:', err)
|
||||
log.error('代理服务启动失败:', err)
|
||||
}
|
||||
}
|
||||
if (conf.proxy.enabled) {
|
||||
try {
|
||||
await proxy.start()
|
||||
} catch (err) {
|
||||
console.error('开启系统代理失败:', err)
|
||||
log.error('开启系统代理失败:', err)
|
||||
}
|
||||
}
|
||||
try {
|
||||
|
@ -60,9 +62,9 @@ module.exports = {
|
|||
const start = async () => {
|
||||
try {
|
||||
await plugin[key].start()
|
||||
console.log(`插件【${key}】已启动`)
|
||||
log.info(`插件【${key}】已启动`)
|
||||
} catch (err) {
|
||||
console.log(`插件【${key}】启动失败`, err)
|
||||
log.error(`插件【${key}】启动失败`, err)
|
||||
}
|
||||
}
|
||||
plugins.push(start())
|
||||
|
@ -72,7 +74,7 @@ module.exports = {
|
|||
await Promise.all(plugins)
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('开启插件失败:', err)
|
||||
log.error('开启插件失败:', err)
|
||||
}
|
||||
},
|
||||
shutdown: async () => {
|
||||
|
@ -83,9 +85,9 @@ module.exports = {
|
|||
const close = async () => {
|
||||
try {
|
||||
await plugin[key].close()
|
||||
console.log(`插件【${key}】已关闭`)
|
||||
log.info(`插件【${key}】已关闭`)
|
||||
} catch (err) {
|
||||
console.log(`插件【${key}】关闭失败`, err)
|
||||
log.info(`插件【${key}】关闭失败`, err)
|
||||
}
|
||||
}
|
||||
plugins.push(close())
|
||||
|
@ -95,23 +97,23 @@ module.exports = {
|
|||
await Promise.all(plugins)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('插件关闭失败'.error)
|
||||
log.error('插件关闭失败'.error)
|
||||
}
|
||||
|
||||
if (status.proxy.enabled) {
|
||||
try {
|
||||
await proxy.close()
|
||||
console.log('系统代理已关闭')
|
||||
log.info('系统代理已关闭')
|
||||
} catch (err) {
|
||||
console.error('系统代理关闭失败', err)
|
||||
log.error('系统代理关闭失败', err)
|
||||
}
|
||||
}
|
||||
if (status.server.enabled) {
|
||||
try {
|
||||
await server.close()
|
||||
console.log('代理服务已关闭')
|
||||
log.info('代理服务已关闭')
|
||||
} catch (err) {
|
||||
console.error('代理服务关闭失败', err)
|
||||
log.error('代理服务关闭失败', err)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const expose = require('./expose.js')
|
||||
|
||||
const log = require('./utils/util.log')
|
||||
// process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'
|
||||
|
||||
// 避免异常崩溃
|
||||
|
@ -8,11 +8,11 @@ process.on('uncaughtException', function (err) {
|
|||
// console.error(err.errno)
|
||||
return
|
||||
}
|
||||
console.error('uncaughtException', err)
|
||||
log.error('uncaughtException', err)
|
||||
})
|
||||
|
||||
process.on('unhandledRejection', (reason, p) => {
|
||||
console.log('Unhandled Rejection at: Promise', p, 'reason:', reason)
|
||||
log.error('Unhandled Rejection at: Promise', p, 'reason:', reason)
|
||||
// application specific logging, throwing an error, or other logic here
|
||||
})
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
const nodeConfig = require('./config')
|
||||
const NodePlugin = function (context) {
|
||||
const { config, shell, event, rootCaFile } = context
|
||||
const { config, shell, event, rootCaFile, log } = context
|
||||
const nodeApi = {
|
||||
async start () {
|
||||
try {
|
||||
await nodeApi.setVariables()
|
||||
} catch (err) {
|
||||
console.warn('set variables error', err)
|
||||
log.warn('set variables error', err)
|
||||
}
|
||||
|
||||
const ip = '127.0.0.1'
|
||||
|
@ -123,7 +123,7 @@ const NodePlugin = function (context) {
|
|||
await shell.setSystemEnv({ list: env })
|
||||
}
|
||||
event.fire('status', { key: 'plugin.node.enabled', value: true })
|
||||
console.info('开启【NPM】代理成功')
|
||||
log.info('开启【NPM】代理成功')
|
||||
|
||||
return ret
|
||||
},
|
||||
|
@ -137,7 +137,7 @@ const NodePlugin = function (context) {
|
|||
]
|
||||
const ret = await shell.exec(cmds, { type: 'cmd' })
|
||||
event.fire('status', { key: 'plugin.node.enabled', value: false })
|
||||
console.info('关闭【NPM】代理成功')
|
||||
log.info('关闭【NPM】代理成功')
|
||||
return ret
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const ProxyPlugin = function (context) {
|
||||
const { config, event, shell } = context
|
||||
const { config, event, shell, log } = context
|
||||
const api = {
|
||||
async start () {
|
||||
return api.setProxy()
|
||||
|
@ -13,7 +13,7 @@ const ProxyPlugin = function (context) {
|
|||
const ip = '127.0.0.1'
|
||||
const port = config.get().server.port
|
||||
await shell.setSystemProxy({ ip, port })
|
||||
console.log(`开启系统代理成功:${ip}:${port}`)
|
||||
log.info(`开启系统代理成功:${ip}:${port}`)
|
||||
event.fire('status', { key: 'proxy.enabled', value: true })
|
||||
return { ip, port }
|
||||
},
|
||||
|
@ -22,10 +22,10 @@ const ProxyPlugin = function (context) {
|
|||
try {
|
||||
await shell.setSystemProxy()
|
||||
event.fire('status', { key: 'proxy.enabled', vlaue: false })
|
||||
console.log('关闭系统代理成功')
|
||||
log.info('关闭系统代理成功')
|
||||
return true
|
||||
} catch (err) {
|
||||
console.error('关闭系统代理失败', err)
|
||||
log.error('关闭系统代理失败', err)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ const event = require('../../event')
|
|||
const status = require('../../status')
|
||||
const lodash = require('lodash')
|
||||
const fork = require('child_process').fork
|
||||
const log = require('../../utils/util.log')
|
||||
let server
|
||||
function fireStatus (status) {
|
||||
event.fire('status', { key: 'server.enabled', value: status })
|
||||
|
@ -53,7 +54,7 @@ const serverApi = {
|
|||
}
|
||||
}
|
||||
serverProcess.on('message', function (msg) {
|
||||
console.log('收到子进程消息', msg)
|
||||
log.info('收到子进程消息', msg)
|
||||
if (msg.type === 'status') {
|
||||
fireStatus(msg.event)
|
||||
} else if (msg.type === 'error') {
|
||||
|
@ -81,21 +82,21 @@ const serverApi = {
|
|||
// fireStatus('ing')// 关闭中
|
||||
server.close((err) => {
|
||||
if (err) {
|
||||
console.log('close error', err, ',', err.code, ',', err.message, ',', err.errno)
|
||||
log.info('close error', err, ',', err.code, ',', err.message, ',', err.errno)
|
||||
if (err.code === 'ERR_SERVER_NOT_RUNNING') {
|
||||
console.log('代理服务关闭成功')
|
||||
log.info('代理服务关闭成功')
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
console.log('代理服务关闭失败', err)
|
||||
log.info('代理服务关闭失败', err)
|
||||
reject(err)
|
||||
} else {
|
||||
console.log('代理服务关闭成功')
|
||||
log.info('代理服务关闭成功')
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
console.log('server is null')
|
||||
log.info('server is null')
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
|
|
|
@ -7,7 +7,7 @@ const Registry = require('winreg')
|
|||
// const cmd = require('node-cmd')
|
||||
const refreshInternetPs = require('./refresh-internet')
|
||||
const PowerShell = require('node-powershell')
|
||||
|
||||
const log = require('../../../utils/util.log')
|
||||
const _lanIP = [
|
||||
'localhost',
|
||||
'127.*',
|
||||
|
@ -42,9 +42,9 @@ async function _winUnsetProxy (exec) {
|
|||
_winAsyncRegSet(regKey, 'ProxyEnable', Registry.REG_DWORD, 0),
|
||||
_winAsyncRegSet(regKey, 'ProxyServer', Registry.REG_SZ, '')
|
||||
])
|
||||
console.log('代理关闭成功,等待refresh')
|
||||
log.info('代理关闭成功,等待refresh')
|
||||
await exec(refreshInternetPs, { type: 'ps' })
|
||||
console.log('代理关闭refresh完成')
|
||||
log.info('代理关闭refresh完成')
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ async function _winSetProxy (exec, ip, port) {
|
|||
for (const string of _lanIP) {
|
||||
lanIpStr += string + ';'
|
||||
}
|
||||
// console.log('lanIps:', lanIpStr, ip, port)
|
||||
// log.info('lanIps:', lanIpStr, ip, port)
|
||||
await Promise.all([
|
||||
_winAsyncRegSet(regKey, 'MigrateProxy', Registry.REG_DWORD, 1),
|
||||
_winAsyncRegSet(regKey, 'ProxyEnable', Registry.REG_DWORD, 1),
|
||||
|
@ -66,9 +66,9 @@ async function _winSetProxy (exec, ip, port) {
|
|||
_winAsyncRegSet(regKey, 'ProxyServer', Registry.REG_SZ, `${ip}:${port}`),
|
||||
_winAsyncRegSet(regKey, 'ProxyOverride', Registry.REG_SZ, lanIpStr)
|
||||
])
|
||||
console.log('代理设置成功,等待refresh')
|
||||
log.info('代理设置成功,等待refresh')
|
||||
await exec(refreshInternetPs)
|
||||
console.log('代理设置refresh完成')
|
||||
log.info('代理设置refresh完成')
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -84,32 +84,16 @@ function _winAsyncRegSet (regKey, name, type, value) {
|
|||
})
|
||||
}
|
||||
|
||||
async function _winResetWininetProxySettings (script) {
|
||||
const ps = new PowerShell({
|
||||
executionPolicy: 'Bypass',
|
||||
noProfile: true
|
||||
})
|
||||
ps.addCommand(script)
|
||||
|
||||
try {
|
||||
const ret = await ps.invoke()
|
||||
console.log('ps complete', script)
|
||||
return ret
|
||||
} finally {
|
||||
ps.dispose()
|
||||
}
|
||||
}
|
||||
|
||||
const executor = {
|
||||
async windows (exec, params) {
|
||||
if (params == null) {
|
||||
// 清空代理
|
||||
console.log('关闭代理')
|
||||
log.info('关闭代理')
|
||||
return _winUnsetProxy(exec)
|
||||
} else {
|
||||
// 设置代理
|
||||
const { ip, port } = params
|
||||
console.log('设置代理', ip, port)
|
||||
log.info('设置代理', ip, port)
|
||||
return _winSetProxy(exec, ip, port)
|
||||
}
|
||||
},
|
||||
|
|
|
@ -4,7 +4,7 @@ const childProcess = require('child_process')
|
|||
const _exec = childProcess.exec
|
||||
const exec = util.promisify(_exec)
|
||||
const PowerShell = require('node-powershell')
|
||||
|
||||
const log = require('../utils/util.log')
|
||||
class SystemShell {
|
||||
static async exec (cmds, args) {
|
||||
throw new Error('You have to implement the method exec!')
|
||||
|
@ -52,7 +52,7 @@ class WindowsSystemShell extends SystemShell {
|
|||
|
||||
try {
|
||||
const ret = await ps.invoke()
|
||||
// console.log('ps complete', cmds)
|
||||
// log.info('ps complete', cmds)
|
||||
return ret
|
||||
} finally {
|
||||
ps.dispose()
|
||||
|
@ -64,7 +64,7 @@ class WindowsSystemShell extends SystemShell {
|
|||
}
|
||||
// compose += '&& exit'
|
||||
const ret = await childExec(compose)
|
||||
// console.log('cmd complete:', compose)
|
||||
// log.info('cmd complete:', compose)
|
||||
return ret
|
||||
}
|
||||
}
|
||||
|
@ -75,13 +75,13 @@ function childExec (composeCmds) {
|
|||
const childProcess = require('child_process')
|
||||
childProcess.exec(composeCmds, function (error, stdout, stderr) {
|
||||
if (error) {
|
||||
console.error('cmd 命令执行错误:', composeCmds, error, stderr)
|
||||
log.error('cmd 命令执行错误:', composeCmds, error, stderr)
|
||||
reject(error)
|
||||
} else {
|
||||
// console.log('cmd 命令完成:', stdout)
|
||||
// log.info('cmd 命令完成:', stdout)
|
||||
resolve(stdout)
|
||||
}
|
||||
// console.log('关闭 cmd')
|
||||
// log.info('关闭 cmd')
|
||||
// ps.kill('SIGINT')
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
const event = require('./event')
|
||||
const lodash = require('lodash')
|
||||
const log = require('./utils/util.log')
|
||||
const status = {
|
||||
server: { enabled: false },
|
||||
proxy: {},
|
||||
|
@ -8,7 +9,7 @@ const status = {
|
|||
|
||||
event.register('status', (event) => {
|
||||
lodash.set(status, event.key, event.value)
|
||||
console.log('status changed:', event)
|
||||
log.info('status changed:', event)
|
||||
}, -999)
|
||||
|
||||
module.exports = status
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
const os = require('os')
|
||||
module.exports = {
|
||||
isWindows7 () {
|
||||
const version = os.release()
|
||||
}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
const os = require('os')
|
||||
const util = {
|
||||
getNodeVersion () {
|
||||
const version = process.version
|
||||
console.log(version)
|
||||
}
|
||||
}
|
||||
util.getNodeVersion()
|
||||
module.exports = util
|
|
@ -0,0 +1,12 @@
|
|||
const log4js = require('log4js')
|
||||
const path = require('path')
|
||||
const getDefaultConfigBasePath = function () {
|
||||
const userHome = process.env.HOME || process.env.USERPROFILE
|
||||
return path.resolve(userHome, './.dev-sidecar')
|
||||
}
|
||||
log4js.configure({
|
||||
appenders: { std: { type: 'stdout' }, file: { type: 'file', pattern: '.yyyy-MM-dd', daysToKeep: 3, filename: getDefaultConfigBasePath() + '/logs/server.log' } },
|
||||
categories: { default: { appenders: ['file', 'std'], level: 'info' } }
|
||||
})
|
||||
const logger = log4js.getLogger('server')
|
||||
module.exports = logger
|
|
@ -14,6 +14,7 @@
|
|||
},
|
||||
"main": "background.js",
|
||||
"dependencies": {
|
||||
"log4js": "^6.3.0",
|
||||
"@docmirror/dev-sidecar": "^1.1.0",
|
||||
"@docmirror/mitmproxy": "^1.1.0",
|
||||
"ant-design-vue": "^1.6.5",
|
||||
|
|
|
@ -6,7 +6,7 @@ import { createProtocol } from 'vue-cli-plugin-electron-builder/lib'
|
|||
import bridge from './bridge/index'
|
||||
import updateHandle from './bridge/update-handle'
|
||||
import { ebtMain } from './tongji'
|
||||
|
||||
import log from './utils/util.log'
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const isMac = process.platform === 'darwin'
|
||||
|
||||
|
@ -60,7 +60,7 @@ function setTray (app) {
|
|||
// appTray.setContextMenu(contextMenu)
|
||||
|
||||
// appTray.on('double-click', function () {
|
||||
// console.log('double click')
|
||||
// log.info('double click')
|
||||
// win.show()
|
||||
// })
|
||||
appTray.on('right-click', function (event, bounds) {
|
||||
|
@ -122,13 +122,13 @@ app.disableHardwareAcceleration() // 禁用gpu
|
|||
// 禁止双开
|
||||
const isFirstInstance = app.requestSingleInstanceLock()
|
||||
if (!isFirstInstance) {
|
||||
console.log('is second instance')
|
||||
log.info('is second instance')
|
||||
setTimeout(() => {
|
||||
app.quit()
|
||||
}, 1000)
|
||||
} else {
|
||||
app.on('before-quit', async (event) => {
|
||||
console.log('before-quit')
|
||||
log.info('before-quit')
|
||||
event.preventDefault()
|
||||
// if (tray) {
|
||||
// tray.displayBalloon({ title: '正在关闭,请稍候...', content: '正在关闭中,请稍候。。。' })
|
||||
|
@ -137,7 +137,7 @@ if (!isFirstInstance) {
|
|||
app.exit()
|
||||
})
|
||||
app.on('second-instance', (event, commandLine, workingDirectory) => {
|
||||
console.log('new app started', commandLine)
|
||||
log.info('new app started', commandLine)
|
||||
if (win) {
|
||||
win.show()
|
||||
win.focus()
|
||||
|
@ -170,7 +170,7 @@ if (!isFirstInstance) {
|
|||
// try {
|
||||
// await installExtension(VUEJS_DEVTOOLS)
|
||||
// } catch (e) {
|
||||
// console.error('Vue Devtools failed to install:', e.toString())
|
||||
// log.error('Vue Devtools failed to install:', e.toString())
|
||||
// }
|
||||
}
|
||||
createWindow()
|
||||
|
@ -196,7 +196,7 @@ if (!isFirstInstance) {
|
|||
// 最小化到托盘
|
||||
tray = setTray(app)
|
||||
} catch (err) {
|
||||
console.log('err', err)
|
||||
log.info('err', err)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import JSON5 from 'json5'
|
|||
import path from 'path'
|
||||
const pk = require('../../package.json')
|
||||
const mitmproxyPath = path.join(__dirname, 'mitmproxy.js')
|
||||
|
||||
const log = require('../utils/util.log')
|
||||
const getDefaultConfigBasePath = function () {
|
||||
const userHome = process.env.HOME || process.env.USERPROFILE
|
||||
return path.resolve(userHome, './.dev-sidecar')
|
||||
|
@ -22,12 +22,12 @@ const localApi = {
|
|||
lodash.merge(core, local)
|
||||
const list = []
|
||||
_deepFindFunction(list, core, '')
|
||||
// console.log('api list:', list)
|
||||
// log.info('api list:', list)
|
||||
return list
|
||||
},
|
||||
info: {
|
||||
get () {
|
||||
console.log(pk)
|
||||
log.info(pk)
|
||||
return {
|
||||
version: pk.version
|
||||
}
|
||||
|
@ -182,23 +182,23 @@ export default {
|
|||
target = lodash.get(DevSidecar.api, api)
|
||||
}
|
||||
if (target == null) {
|
||||
console.log('找不到此接口方法:', api)
|
||||
log.info('找不到此接口方法:', api)
|
||||
}
|
||||
let param
|
||||
if (args.length >= 2) {
|
||||
param = args[1]
|
||||
}
|
||||
const ret = target(param)
|
||||
// console.log('api:', api, 'ret:', ret)
|
||||
// log.info('api:', api, 'ret:', ret)
|
||||
return ret
|
||||
})
|
||||
// 注册从core里来的事件,并转发给view
|
||||
DevSidecar.api.event.register('status', (event) => {
|
||||
console.log('bridge on status', event)
|
||||
log.info('bridge on status', event)
|
||||
win.webContents.send('status', { ...event })
|
||||
})
|
||||
DevSidecar.api.event.register('error', (event) => {
|
||||
console.error('bridge on error', event)
|
||||
log.error('bridge on error', event)
|
||||
win.webContents.send('error.core', event)
|
||||
})
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { ipcMain, dialog } from 'electron'
|
||||
import { autoUpdater } from 'electron-updater'
|
||||
import log from '../utils/util.log'
|
||||
import path from 'path'
|
||||
// win是所有窗口的引用
|
||||
// const path = require('path') // 引入path模块
|
||||
|
@ -31,30 +32,30 @@ function updateHandle (win, updateUrl) {
|
|||
url: updateUrl
|
||||
})
|
||||
autoUpdater.on('error', function (error) {
|
||||
console.log('autoUpdater error', error)
|
||||
log.info('autoUpdater error', error)
|
||||
sendUpdateMessage({ key: 'error', value: error, error: error })
|
||||
// dialog.showErrorBox('Error: ', error == null ? 'unknown' : (error.stack || error).toString())
|
||||
})
|
||||
autoUpdater.on('checking-for-update', function () {
|
||||
console.log('autoUpdater checking-for-update')
|
||||
log.info('autoUpdater checking-for-update')
|
||||
sendUpdateMessage({ key: 'checking', value: message.checking })
|
||||
})
|
||||
autoUpdater.on('update-available', function (info) {
|
||||
console.log('autoUpdater update-available')
|
||||
log.info('autoUpdater update-available')
|
||||
sendUpdateMessage({ key: 'available', value: info })
|
||||
})
|
||||
autoUpdater.on('update-not-available', function (info) {
|
||||
console.log('autoUpdater update-not-available')
|
||||
log.info('autoUpdater update-not-available')
|
||||
sendUpdateMessage({ key: 'notAvailable', value: message.updateNotAva })
|
||||
})
|
||||
// 更新下载进度
|
||||
autoUpdater.on('download-progress', function (progressObj) {
|
||||
console.log('autoUpdater download-progress')
|
||||
log.info('autoUpdater download-progress')
|
||||
win.webContents.send('update', { key: 'progress', value: parseInt(progressObj.percent) })
|
||||
})
|
||||
// 更新完成,重启应用
|
||||
autoUpdater.on('update-downloaded', function (info) {
|
||||
console.log('download complete', info.version)
|
||||
log.info('download complete', info.version)
|
||||
win.webContents.send('update', {
|
||||
key: 'downloaded',
|
||||
value: {
|
||||
|
@ -70,21 +71,21 @@ function updateHandle (win, updateUrl) {
|
|||
autoUpdater.quitAndInstall()
|
||||
} else if (arg.key === 'checkForUpdate') {
|
||||
// 执行自动更新检查
|
||||
console.log('autoUpdater checkForUpdates')
|
||||
log.info('autoUpdater checkForUpdates')
|
||||
autoUpdater.checkForUpdates()
|
||||
} else if (arg.key === 'downloadUpdate') {
|
||||
// 下载新版本
|
||||
console.log('autoUpdater downloadUpdate')
|
||||
log.info('autoUpdater downloadUpdate')
|
||||
autoUpdater.downloadUpdate()
|
||||
}
|
||||
})
|
||||
// 通过main进程发送事件给renderer进程,提示更新信息
|
||||
function sendUpdateMessage (message) {
|
||||
console.log('autoUpdater sendUpdateMessage')
|
||||
log.info('autoUpdater sendUpdateMessage')
|
||||
win.webContents.send('update', message)
|
||||
}
|
||||
|
||||
console.log('auto update inited')
|
||||
log.info('auto update inited')
|
||||
return autoUpdater
|
||||
}
|
||||
export default updateHandle
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
const log4js = require('log4js')
|
||||
const path = require('path')
|
||||
const getDefaultConfigBasePath = function () {
|
||||
const userHome = process.env.HOME || process.env.USERPROFILE
|
||||
return path.resolve(userHome, './.dev-sidecar')
|
||||
}
|
||||
log4js.configure({
|
||||
appenders: { std: { type: 'stdout' }, file: { type: 'file', pattern: '.yyyy-MM-dd', daysToKeep: 3, filename: getDefaultConfigBasePath() + '/logs/server.log' } },
|
||||
categories: { default: { appenders: ['file', 'std'], level: 'info' } }
|
||||
})
|
||||
const logger = log4js.getLogger('server')
|
||||
module.exports = logger
|
Loading…
Reference in New Issue