diff --git a/Application/Base/Tool/GameResource/YjlyClient.class.php b/Application/Base/Tool/GameResource/YjlyClient.class.php index 241a89ec3..5884c5185 100644 --- a/Application/Base/Tool/GameResource/YjlyClient.class.php +++ b/Application/Base/Tool/GameResource/YjlyClient.class.php @@ -5,7 +5,7 @@ namespace Base\Tool\GameResource; use Base\Tool\Log; use Exception; use GuzzleHttp\Client; -use GuzzleHttp\Exception\RequestException; +use Think\Log as ThinkLog; /** * 御剑灵域-测试资源接口 @@ -51,14 +51,14 @@ class YjlyClient return $this->request($api, $params); } catch (\Exception $e) { $env = C('APP_ENV', null, 'prod'); - Log::error('Yjly ' . $e->getMessage()); + $this->log($e->getMessage(), ThinkLog::ERR); return ['status' => 0, 'msg' => '接口请求错误。' . ($env == 'prod' ? '' : $e->getMessage()) , 'data' => []]; } } public function request($api, $params) { - Log::info('Yjly-params: ' . json_encode($params)); + $this->log('params: ' . json_encode($params)); if ($api['method'] == 'get') { return $this->get($api['uri'], $params); } else { @@ -73,7 +73,7 @@ class YjlyClient 'form_params' => $params, ]); $result = (string)$response->getBody(); - Log::info('Yjly-response: ' . $result); + $this->log('response: ' . $result); return json_decode($result, true); } @@ -84,7 +84,7 @@ class YjlyClient 'query' => $params, ]); $result = (string)$response->getBody(); - Log::info('Yjly-response: ' . $result); + $this->log('response: ' . $result); return json_decode($result, true); } @@ -105,7 +105,7 @@ class YjlyClient $signString .= $params['orderNum']; $signString .= $params['time']; $signString .= self::SIGN_KEY; - Log::info('Yjly-signString: ' . $signString); + $this->log('signString: ' . $signString); return md5($signString); } @@ -223,4 +223,8 @@ class YjlyClient { return []; } + + protected function log($message, $level = ThinkLog::INFO) { + Log::write($message, $level, 'game_api/yjly'); + } } \ No newline at end of file diff --git a/Application/Base/Tool/Log.class.php b/Application/Base/Tool/Log.class.php index cce8fe15a..6bf8bae68 100644 --- a/Application/Base/Tool/Log.class.php +++ b/Application/Base/Tool/Log.class.php @@ -45,7 +45,7 @@ class Log self::write($content, BaseLog::EMERG, $fileName); } - private static function write($content, $level, $fileName) + public static function write($content, $level, $fileName) { $fileName = $fileName == '' ? 'app' : $fileName; $destination = RUNTIME_PATH . 'Logs/Common/' . $fileName . '_' . date('y_m_d') . '.log';