From 52e1d04e09db5dec37934731a7f270db9725f1be Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Fri, 20 Nov 2020 16:05:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E4=BC=98=E9=80=89=E9=80=BB=E8=BE=91=E9=94=99=E8=AF=AF=E7=9A=84?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/src/utils/util.log.js | 2 +- packages/gui/src/utils/util.log.js | 2 +- packages/mitmproxy/src/lib/choice/index.js | 4 ++-- packages/mitmproxy/src/lib/interceptor/impl/proxy.js | 1 + packages/mitmproxy/src/utils/util.log.js | 4 ++-- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/core/src/utils/util.log.js b/packages/core/src/utils/util.log.js index e1ea2ae6..fa03c416 100644 --- a/packages/core/src/utils/util.log.js +++ b/packages/core/src/utils/util.log.js @@ -5,7 +5,7 @@ const getDefaultConfigBasePath = function () { 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' } }, + appenders: { std: { type: 'stdout' }, file: { type: 'file', pattern: 'yyyy-MM-dd', daysToKeep: 3, filename: getDefaultConfigBasePath() + '/logs/core.log' } }, categories: { default: { appenders: ['file', 'std'], level: 'info' } } }) const logger = log4js.getLogger('server') diff --git a/packages/gui/src/utils/util.log.js b/packages/gui/src/utils/util.log.js index e1ea2ae6..3ca9d959 100644 --- a/packages/gui/src/utils/util.log.js +++ b/packages/gui/src/utils/util.log.js @@ -5,7 +5,7 @@ const getDefaultConfigBasePath = function () { 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' } }, + appenders: { std: { type: 'stdout' }, file: { type: 'file', pattern: 'yyyy-MM-dd', daysToKeep: 3, filename: getDefaultConfigBasePath() + '/logs/gui.log' } }, categories: { default: { appenders: ['file', 'std'], level: 'info' } } }) const logger = log4js.getLogger('server') diff --git a/packages/mitmproxy/src/lib/choice/index.js b/packages/mitmproxy/src/lib/choice/index.js index 3ee73df7..e7b8a6e2 100644 --- a/packages/mitmproxy/src/lib/choice/index.js +++ b/packages/mitmproxy/src/lib/choice/index.js @@ -33,9 +33,8 @@ class DynamicChoice { * @param backupList */ setBackupList (backupList) { - this.value = backupList.shift() this.backup = backupList - let defaultTotal = backupList.length > 6 ? backupList.length : 6 + let defaultTotal = backupList.length for (const item of backupList) { if (this.count[item]) { continue @@ -43,6 +42,7 @@ class DynamicChoice { this.count[item] = { value: item, total: defaultTotal, error: 0, keepErrorCount: 0, successRate: 1 } defaultTotal-- } + this.value = backupList.shift() this.doCount(this.value, false) } diff --git a/packages/mitmproxy/src/lib/interceptor/impl/proxy.js b/packages/mitmproxy/src/lib/interceptor/impl/proxy.js index 4dfe7842..b0b4f6c6 100644 --- a/packages/mitmproxy/src/lib/interceptor/impl/proxy.js +++ b/packages/mitmproxy/src/lib/interceptor/impl/proxy.js @@ -50,6 +50,7 @@ module.exports = { rOptions.port = rOptions.protocol === 'https:' ? 443 : 80 } log.info('proxy:', rOptions.hostname, proxyTarget) + log.debug('proxy choice:', JSON.stringify(context.requestCount)) return true }, is (interceptOpt) { diff --git a/packages/mitmproxy/src/utils/util.log.js b/packages/mitmproxy/src/utils/util.log.js index cba5331c..c339f7a8 100644 --- a/packages/mitmproxy/src/utils/util.log.js +++ b/packages/mitmproxy/src/utils/util.log.js @@ -1,8 +1,8 @@ const log4js = require('log4js') const proxyConfig = require('../lib/proxy/common/config') log4js.configure({ - appenders: { std: { type: 'stdout' }, file: { type: 'file', pattern: 'yyyy-MM-dd', daysToKeep: 3, filename: proxyConfig.getDefaultCABasePath() + '/logs/server.log' } }, - categories: { default: { appenders: ['file', 'std'], level: 'info' } } + appenders: { std: { type: 'stdout', level: 'debug' }, file: { type: 'file', pattern: 'yyyy-MM-dd', daysToKeep: 3, filename: proxyConfig.getDefaultCABasePath() + '/logs/server.log' } }, + categories: { default: { appenders: ['file', 'std'], level: 'debug' } } }) const logger = log4js.getLogger('server') module.exports = logger