Skip to content

Commit

Permalink
日志优化
Browse files Browse the repository at this point in the history
  • Loading branch information
wangliang181230 committed Oct 17, 2024
1 parent be7b0d2 commit 9b13575
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/mitmproxy/src/utils/util.match.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,17 @@ function matchHostname (hostMap, hostname, action) {
// 域名快速匹配:直接匹配 或者 两种前缀通配符匹配
let value = hostMap.origin[hostname]
if (value) {
log.info(`matchHostname: ${action}: '${hostname}' -> '${hostname}': ${JSON.stringify(value)}`)
log.info(`matchHostname: ${action}: '${hostname}' -> { "${hostname}": ${JSON.stringify(value)} }`)
return value // 快速匹配成功
}
value = hostMap.origin['*' + hostname]
if (value) {
log.info(`matchHostname: ${action}: '${hostname}' -> '*${hostname}': ${JSON.stringify(value)}`)
log.info(`matchHostname: ${action}: '${hostname}' -> { "*${hostname}": ${JSON.stringify(value)} }`)
return value // 快速匹配成功
}
value = hostMap.origin['*.' + hostname]
if (value) {
log.info(`matchHostname: ${action}: '${hostname}' -> '*.${hostname}': ${JSON.stringify(value)}`)
log.info(`matchHostname: ${action}: '${hostname}' -> { "*.${hostname}": ${JSON.stringify(value)} }`)
return value // 快速匹配成功
}

Expand Down Expand Up @@ -145,7 +145,7 @@ function matchHostnameAll (hostMap, hostname, action) {
// 正则表达式匹配
if (hostname.match(regexp)) {
value = hostMap[target]
log.debug(`matchHostname-one: ${action}: '${hostname}' -> '${target}': ${JSON.stringify(value)}`)
log.debug(`matchHostname-one: ${action}: '${hostname}' -> { "${target}": ${JSON.stringify(value)} }`)
values = merge(values, value)
}
}
Expand All @@ -154,19 +154,19 @@ function matchHostnameAll (hostMap, hostname, action) {
// 优先级:2
value = hostMap.origin['*' + hostname]
if (value) {
log.debug(`matchHostname-one: ${action}: '${hostname}' -> '*${hostname}': ${JSON.stringify(value)}`)
log.debug(`matchHostname-one: ${action}: '${hostname}' -> { "*${hostname}": ${JSON.stringify(value)} }`)
values = merge(values, value)
}
// 优先级:3
value = hostMap.origin['*.' + hostname]
if (value) {
log.debug(`matchHostname-one: ${action}: '${hostname}' -> '*.${hostname}': ${JSON.stringify(value)}`)
log.debug(`matchHostname-one: ${action}: '${hostname}' -> { "*.${hostname}": ${JSON.stringify(value)} }`)
values = merge(values, value)
}
// 优先级:4,最高(注:优先级高的配置,可以覆盖优先级低的配置,甚至有空配置时,可以移除已有配置)
value = hostMap.origin[hostname]
if (value) {
log.debug(`matchHostname-one: ${action}: '${hostname}' -> '${hostname}': ${JSON.stringify(value)}`)
log.debug(`matchHostname-one: ${action}: '${hostname}' -> { "${hostname}": ${JSON.stringify(value)} }`)
values = merge(values, value)
}

Expand Down

0 comments on commit 9b13575

Please sign in to comment.