日志升级与缓存修复最终版
This commit is contained in:
@@ -41,14 +41,47 @@ if (!function_exists('cloak_api_reason')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('cloak_cache_hit_log_reason')) {
|
||||
/**
|
||||
* 缓存判定落库 reason:true 为空;false 固定为「缓存」。
|
||||
*
|
||||
* @param string $result
|
||||
*/
|
||||
function cloak_cache_hit_log_reason($result)
|
||||
{
|
||||
return cloak_normalize_log_reason((string) $result, (string) $result === 'true' ? '' : '缓存');
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('cloak_normalize_log_reason')) {
|
||||
/**
|
||||
* 落库 reason 规范化:true 必须为空;false 必须有值;wait 保留检测中文案。
|
||||
*
|
||||
* @param string $result
|
||||
* @param mixed $reason
|
||||
*/
|
||||
function cloak_normalize_log_reason($result, $reason)
|
||||
{
|
||||
$result = (string) $result;
|
||||
$reason = trim((string) $reason);
|
||||
|
||||
if ($result === 'true') {
|
||||
return '';
|
||||
}
|
||||
if ($result === 'wait') {
|
||||
return $reason !== '' ? $reason : '二次风控检测中';
|
||||
}
|
||||
if ($reason === '') {
|
||||
return '判定拒绝(安全页)';
|
||||
}
|
||||
return $reason;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('cloak_finalize_reason')) {
|
||||
function cloak_finalize_reason($reason, $checkResult)
|
||||
{
|
||||
$reason = trim((string) $reason);
|
||||
if ($reason !== '') {
|
||||
return $reason;
|
||||
}
|
||||
$pass = ($checkResult === 'true');
|
||||
return $pass ? '判定通过(真实页)' : '判定拒绝(安全页)';
|
||||
$result = ($checkResult === 'true') ? 'true' : (($checkResult === 'false') ? 'false' : (string) $checkResult);
|
||||
return cloak_normalize_log_reason($result, $reason);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user