Skip to content

Commit

Permalink
optimize: 日志优化。
Browse files Browse the repository at this point in the history
  • Loading branch information
wangliang181230 committed Oct 16, 2024
1 parent 01bf014 commit eddc285
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions packages/mitmproxy/src/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ module.exports = {
// 仅用于记录日志时使用
stringify2 (obj) {
try {
return JSON5.stringify(obj)
return JSON.stringify(obj)
} catch (e) {
log.debug('转换为JSON字符串失败, error:', e, ', obj:', obj)
return obj
try {
return JSON5.stringify(obj)
} catch (e2) {
log.debug('转换为JSON字符串失败, error:', e, ', obj:', obj)
return obj
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ module.exports = function createRequestHandler (createIntercepts, middlewares, e
function onFree () {
url = `${rOptions.method}${rOptions.protocol}//${rOptions.hostname}:${rOptions.port}${rOptions.path}`
const start = new Date()
log.info('发起代理请求:', url, (rOptions.servername ? ', sni: ' + rOptions.servername : ''), ', headers:', rOptions.headers)
log.info('发起代理请求:', url, (rOptions.servername ? ', sni: ' + rOptions.servername : ''), ', headers:', jsonApi.stringify2(rOptions.headers))

const isDnsIntercept = {}
if (dnsConfig && dnsConfig.providers) {
Expand Down

0 comments on commit eddc285

Please sign in to comment.