self::SESSION_BY_REQUEST, 'api_by_response' => self::SESSION_BY_RESPONSE, ]; foreach ($map as $col => $sessionKey) { if (empty($logs[$col]) && !empty($_SESSION[$sessionKey])) { $logs[$col] = (string) $_SESSION[$sessionKey]; } } return $logs; } /** * @param mixed $data */ public static function encode($data) { if (is_string($data)) { return $data; } $json = json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); return $json !== false ? $json : ''; } /** * 日志表格展示:未调用时返回「-」 * * @param mixed $raw */ public static function displayText($raw) { $raw = trim((string) $raw); return $raw === '' ? '-' : $raw; } }