添加日志

master
ELF 3 years ago
parent 73a57d1a14
commit 844ffdcabd

@ -10,6 +10,7 @@ use Base\Service\PartnerService;
use Base\Repository\TestingResourceRepository;
use Base\Repository\GameRepository;
use Base\Service\GameService;
use Base\Tool\Log;
class TestingResourceController extends ThinkController
{
@ -530,6 +531,11 @@ class TestingResourceController extends ThinkController
{
$ids = I('ids', []);
$status = I('status', 0);
$admin = session('user_auth');
Log::info('admin_provide ' . $admin['username'] . ' -- ' . implode(',', $ids) . ' -- ' . $status);
return $this->ajaxReturn(['status' => 0, 'message' => '手动发放暂时关闭']);
if (count($ids) == 0) {
return $this->ajaxReturn(['status' => 0, 'message' => '请选择要审核的批次']);
}

@ -2,6 +2,7 @@
namespace Base\Tool\GameResource;
use Base\Tool\Log;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
@ -41,6 +42,7 @@ class LeyouClient
return $this->request($api, $params);
} catch (\Exception $e) {
$env = C('APP_ENV', null, 'prod');
Log::error('Leyou ' . $e->getMessage());
return $e->getMessage();
}
}
@ -60,7 +62,9 @@ class LeyouClient
'verify' => false,
'form_params' => $params,
]);
return (string)$response->getBody();
$result = (string)$response->getBody();
Log::info('Leyou ' . json_encode($params) . ' ' . $result);
return $result;
}
protected function get($uri, array $params = [])
@ -69,7 +73,9 @@ class LeyouClient
'verify' => false,
'query' => $params,
]);
return (string)$response->getBody();
$result = (string)$response->getBody();
Log::info('Leyou ' . json_encode($params) . ' ' . $result);
return $result;
}
protected function sign($params)

@ -2,6 +2,7 @@
namespace Base\Tool\GameResource;
use Base\Tool\Log;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
@ -39,6 +40,7 @@ class LsxxClient
return $this->request($api, $params);
} catch (\Exception $e) {
$env = C('APP_ENV', null, 'prod');
Log::error('Lsxx ' . $e->getMessage());
return ['status' => 0, 'msg' => '接口请求错误。' . ($env == 'prod' ? '' : $e->getMessage()) , 'data' => []];
}
}
@ -59,6 +61,7 @@ class LsxxClient
'form_params' => $params,
]);
$result = (string)$response->getBody();
Log::info('Lsxx ' . json_encode($params) . ' ' . $result);
return json_decode($result, true);
}
@ -69,6 +72,7 @@ class LsxxClient
'query' => $params,
]);
$result = (string)$response->getBody();
Log::info('Lsxx ' . json_encode($params) . ' ' . $result);
return json_decode($result, true);
}

@ -2,9 +2,9 @@
namespace Base\Tool\GameResource;
use Base\Tool\Log;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
use Think\Log;
/**
* 双倍传奇-测试资源接口
@ -42,6 +42,7 @@ class SbcqClient
return $this->request($api, $params);
} catch (\Exception $e) {
$env = C('APP_ENV', null, 'prod');
Log::error('rebate:SBCQ ' . $e->getMessage());
return ['status' => 'error', 'msg' => '接口请求错误。' . ($env == 'prod' ? '' : $e->getMessage()) , 'data' => []];
}
}
@ -62,7 +63,7 @@ class SbcqClient
'form_params' => $params,
]);
$result = (string)$response->getBody();
Log::record('rebate:SBCQ ' . $uri . ' -- '. json_encode($params) . ' -- '. $result);
Log::info('rebate:SBCQ ' . $uri . ' -- '. json_encode($params) . ' -- '. $result);
return json_decode($result, true);
}
@ -73,7 +74,7 @@ class SbcqClient
'query' => $params,
]);
$result = (string)$response->getBody();
Log::record('rebate:SBCQ ' . $uri . ' -- '. json_encode($params) . ' -- '. $result);
Log::info('rebate:SBCQ ' . $uri . ' -- '. json_encode($params) . ' -- '. $result);
return json_decode($result, true);
}

@ -2,9 +2,9 @@
namespace Base\Tool\GameResource;
use Base\Tool\Log;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
use Think\Log;
/**
* 逍遥游之仙魔降世-测试资源接口
@ -43,6 +43,7 @@ class XyyClient
return $this->request($api, $params);
} catch (\Exception $e) {
$env = C('APP_ENV', null, 'prod');
Log::error('rebate:XYY ' . $e->getMessage());
return ['code' => 3, 'msg' => '接口请求错误。' . ($env == 'prod' ? '' : $e->getMessage()) , 'data' => []];
}
}
@ -63,7 +64,7 @@ class XyyClient
'form_params' => $params,
]);
$result = (string)$response->getBody();
Log::record('rebate:XYY ' . $uri . ' -- '. json_encode($params) . ' -- '. $result);
Log::info('rebate:XYY ' . $uri . ' -- '. json_encode($params) . ' -- '. $result);
return json_decode($result, true);
}
@ -74,7 +75,7 @@ class XyyClient
'query' => $params,
]);
$result = (string)$response->getBody();
Log::record('rebate:XYY ' . $uri . ' -- '. json_encode($params) . ' -- '. $result);
Log::info('rebate:XYY ' . $uri . ' -- '. json_encode($params) . ' -- '. $result);
return json_decode($result, true);
}

@ -2,6 +2,7 @@
namespace Base\Tool\GameResource;
use Base\Tool\Log;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
@ -57,6 +58,7 @@ class YzchzbClient
return $this->request($api, $params);
} catch (\Exception $e) {
$env = C('APP_ENV', null, 'prod');
Log::error($e->getMessage());
return ['code' => 1000, 'state' => 1000, 'message' => '接口请求错误。' . ($env == 'prod' ? '' : $e->getMessage()) , 'data' => []];
}
}
@ -77,6 +79,7 @@ class YzchzbClient
'form_params' => $params,
]);
$result = (string)$response->getBody();
Log::info(json_encode($params) . ' ' . $result);
return json_decode($result, true);
}
@ -87,6 +90,7 @@ class YzchzbClient
'query' => $params,
]);
$result = (string)$response->getBody();
Log::info(json_encode($params) . ' ' . $result);
return json_decode($result, true);
}

@ -0,0 +1,54 @@
<?php
namespace Base\Tool;
use Think\Log as BaseLog;
class Log
{
public static function info($content, $fileName = '')
{
self::write($content, BaseLog::INFO, $fileName);
}
public static function error($content, $fileName = '')
{
self::write($content, BaseLog::ERR, $fileName);
}
public static function debug($content, $fileName = '')
{
self::write($content, BaseLog::DEBUG, $fileName);
}
public static function warning($content, $fileName = '')
{
self::write($content, BaseLog::WARN, $fileName);
}
public static function notice($content, $fileName = '')
{
self::write($content, BaseLog::NOTICE, $fileName);
}
public static function alert($content, $fileName = '')
{
self::write($content, BaseLog::ALERT, $fileName);
}
public static function critical($content, $fileName = '')
{
self::write($content, BaseLog::CRIT, $fileName);
}
public static function emergency($content, $fileName = '')
{
self::write($content, BaseLog::EMERG, $fileName);
}
private static function write($content, $level, $fileName)
{
$fileName = $fileName == '' ? 'app' : $fileName;
$destination = RUNTIME_PATH . 'Logs/Common/' . $fileName . '_' . date('y_m_d') . '.log';
BaseLog::write($content, $level, '', $destination);
}
}
Loading…
Cancel
Save