Skip to content

Commit 8db4c48

Browse files
committed
[更新]修改微信SDK日志格式
1 parent a5ac4d6 commit 8db4c48

File tree

5 files changed

+25
-25
lines changed

5 files changed

+25
-25
lines changed

Wechat/Lib/Common.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public function valid()
116116
if (!isset($array[0]) || intval($array[0]) > 0) {
117117
$this->errCode = $array[0];
118118
$this->errMsg = $array[1];
119-
Tools::log("Interface Authentication Failed. {$this->errMsg}[{$this->errCode}]", "ERR-{$this->appid}");
119+
Tools::log("Interface Authentication Failed. {$this->errMsg}[{$this->errCode}]", "ERR - {$this->appid}");
120120
return false;
121121
}
122122
$this->postxml = $array[1];
@@ -184,11 +184,11 @@ public function getAccessToken($appid = '', $appsecret = '', $token = '')
184184
if (!$json || isset($json['errcode'])) {
185185
$this->errCode = $json['errcode'];
186186
$this->errMsg = $json['errmsg'];
187-
Tools::log("Get New AccessToken Error. {$this->errMsg}[{$this->errCode}]", "ERR-{$this->appid}");
187+
Tools::log("Get New AccessToken Error. {$this->errMsg}[{$this->errCode}]", "ERR - {$this->appid}");
188188
return false;
189189
}
190190
$this->access_token = $json['access_token'];
191-
Tools::log("Get New AccessToken Success.", "MSG-{$this->appid}");
191+
Tools::log("Get New AccessToken Success.", "MSG - {$this->appid}");
192192
Tools::setCache($cache, $this->access_token, 5000);
193193
return $this->access_token;
194194
}
@@ -203,12 +203,12 @@ public function getAccessToken($appid = '', $appsecret = '', $token = '')
203203
*/
204204
protected function checkRetry($method, $arguments = array())
205205
{
206-
Tools::log("Run {$method} Faild. {$this->errMsg}[{$this->errCode}]", "ERR-{$this->appid}");
206+
Tools::log("Run {$method} Faild. {$this->errMsg}[{$this->errCode}]", "ERR - {$this->appid}");
207207
if (!$this->_retry && in_array($this->errCode, array('40014', '40001', '41001', '42001'))) {
208208
($this->_retry = true) && $this->resetAuth();
209209
$this->errCode = 40001;
210210
$this->errMsg = 'no access';
211-
Tools::log("Retry Run {$method} ...", "MSG-{$this->appid}");
211+
Tools::log("Retry Run {$method} ...", "MSG - {$this->appid}");
212212
return call_user_func_array(array($this, $method), $arguments);
213213
}
214214
return false;
@@ -222,7 +222,7 @@ protected function checkRetry($method, $arguments = array())
222222
public function resetAuth($appid = '')
223223
{
224224
$authname = 'wechat_access_token_' . (empty($appid) ? $this->appid : $appid);
225-
Tools::log("Reset Auth And Remove Old AccessToken.", "MSG-{$this->appid}");
225+
Tools::log("Reset Auth And Remove Old AccessToken.", "MSG - {$this->appid}");
226226
$this->access_token = '';
227227
Tools::removeCache($authname);
228228
return true;

Wechat/WechatOauth.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function getOauthAccessToken()
5151
{
5252
$code = isset($_GET['code']) ? $_GET['code'] : '';
5353
if (empty($code)) {
54-
Tools::log("getOauthAccessToken Fail, Because there is no access to the code value in get.", "MSG-{$this->appid}");
54+
Tools::log("getOauthAccessToken Fail, Because there is no access to the code value in get.", "MSG - {$this->appid}");
5555
return false;
5656
}
5757
$result = Tools::httpGet(self::API_BASE_URL_PREFIX . self::OAUTH_TOKEN_URL . "appid={$this->appid}&secret={$this->appsecret}&code={$code}&grant_type=authorization_code");
@@ -60,7 +60,7 @@ public function getOauthAccessToken()
6060
if (empty($json) || !empty($json['errcode'])) {
6161
$this->errCode = isset($json['errcode']) ? $json['errcode'] : '505';
6262
$this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!';
63-
Tools::log("WechatOauth::getOauthAccessToken Fail.{$this->errMsg} [{$this->errCode}]", "ERR-{$this->appid}");
63+
Tools::log("WechatOauth::getOauthAccessToken Fail.{$this->errMsg} [{$this->errCode}]", "ERR - {$this->appid}");
6464
return false;
6565
}
6666
return $json;
@@ -81,7 +81,7 @@ public function getOauthRefreshToken($refresh_token)
8181
if (empty($json) || !empty($json['errcode'])) {
8282
$this->errCode = isset($json['errcode']) ? $json['errcode'] : '505';
8383
$this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!';
84-
Tools::log("WechatOauth::getOauthRefreshToken Fail.{$this->errMsg} [{$this->errCode}]", "ERR-{$this->appid}");
84+
Tools::log("WechatOauth::getOauthRefreshToken Fail.{$this->errMsg} [{$this->errCode}]", "ERR - {$this->appid}");
8585
return false;
8686
}
8787
return $json;
@@ -104,7 +104,7 @@ public function getOauthUserInfo($access_token, $openid)
104104
if (empty($json) || !empty($json['errcode'])) {
105105
$this->errCode = isset($json['errcode']) ? $json['errcode'] : '505';
106106
$this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!';
107-
Tools::log("WechatOauth::getOauthUserInfo Fail.{$this->errMsg} [{$this->errCode}]", "ERR-{$this->appid}");
107+
Tools::log("WechatOauth::getOauthUserInfo Fail.{$this->errMsg} [{$this->errCode}]", "ERR - {$this->appid}");
108108
return false;
109109
}
110110
return $json;
@@ -126,7 +126,7 @@ public function getOauthAuth($access_token, $openid)
126126
if (empty($json) || !empty($json['errcode'])) {
127127
$this->errCode = isset($json['errcode']) ? $json['errcode'] : '505';
128128
$this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!';
129-
Tools::log("WechatOauth::getOauthAuth Fail.{$this->errMsg} [{$this->errCode}]", "ERR-{$this->appid}");
129+
Tools::log("WechatOauth::getOauthAuth Fail.{$this->errMsg} [{$this->errCode}]", "ERR - {$this->appid}");
130130
return false;
131131
} elseif (intval($json['errcode']) === 0) {
132132
return true;

Wechat/WechatPay.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,26 +210,26 @@ public function getNotify()
210210
{
211211
$notifyInfo = (array)simplexml_load_string(file_get_contents("php://input"), 'SimpleXMLElement', LIBXML_NOCDATA);
212212
if (empty($notifyInfo)) {
213-
Tools::log('Payment notification forbidden access.', "ERR-{$this->appid}");
213+
Tools::log('Payment notification forbidden access.', "ERR - {$this->appid}");
214214
$this->errCode = '404';
215215
$this->errMsg = 'Payment notification forbidden access.';
216216
return false;
217217
}
218218
if (empty($notifyInfo['sign'])) {
219-
Tools::log('Payment notification signature is missing.' . var_export($notifyInfo, true), "ERR-{$this->appid}");
219+
Tools::log('Payment notification signature is missing.' . var_export($notifyInfo, true), "ERR - {$this->appid}");
220220
$this->errCode = '403';
221221
$this->errMsg = 'Payment notification signature is missing.';
222222
return false;
223223
}
224224
$data = $notifyInfo;
225225
unset($data['sign']);
226226
if ($notifyInfo['sign'] !== Tools::getPaySign($data, $this->partnerKey)) {
227-
Tools::log('Payment notification signature verification failed.' . var_export($notifyInfo, true), "ERR-{$this->appid}");
227+
Tools::log('Payment notification signature verification failed.' . var_export($notifyInfo, true), "ERR - {$this->appid}");
228228
$this->errCode = '403';
229229
$this->errMsg = 'Payment signature verification failed.';
230230
return false;
231231
}
232-
Tools::log('Payment notification signature verification success.' . var_export($notifyInfo, true), "MSG-{$this->appid}");
232+
Tools::log('Payment notification signature verification success.' . var_export($notifyInfo, true), "MSG - {$this->appid}");
233233
$this->errCode = '0';
234234
$this->errMsg = '';
235235
return $notifyInfo;

Wechat/WechatReceive.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ public function reply($msg = array(), $return = false)
733733
$array = $pc->encrypt($xmldata, empty($this->config['component_appid']) ? $this->appid : $this->config['component_appid']);
734734
$ret = $array[0];
735735
if ($ret != 0) {
736-
Tools::log('Encrypt Error!', "ERR-{$this->appid}");
736+
Tools::log('Encrypt Error!', "ERR - {$this->appid}");
737737
return false;
738738
}
739739
$timestamp = time();

Wechat/WechatService.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,13 @@ public function getComonentTicket()
9797
if (false === $receive->valid()) {
9898
$this->errCode = $receive->errCode;
9999
$this->errMsg = $receive->errMsg;
100-
Tools::log("Get Wechat Push ComponentVerifyTicket Faild. {$this->errMsg} [$this->errCode]", "ERR-{$this->authorizer_appid}");
100+
Tools::log("Get Wechat Push ComponentVerifyTicket Faild. {$this->errMsg} [$this->errCode]", "ERR - {$this->authorizer_appid}");
101101
return false;
102102
}
103103
$data = $receive->getRev()->getRevData();
104104
if ($data['InfoType'] === 'component_verify_ticket' && !empty($data['ComponentVerifyTicket'])) {
105105
# 记录推送日志到微信SDK
106-
Tools::log("Get Wechat Push ComponentVerifyTicket Success. ", "MSG-{$this->authorizer_appid}");
106+
Tools::log("Wechat Push ComponentVerifyTicket Success. ");
107107
Tools::setCache('component_verify_ticket', $data['ComponentVerifyTicket']);
108108
}
109109
return $data;
@@ -130,7 +130,7 @@ public function refreshAccessToken($authorizer_appid, $authorizer_refresh_token)
130130
$url = self::URL_PREFIX . self::REFRESH_ACCESS_TOKEN . "?component_access_token={$this->component_access_token}";
131131
$result = Tools::httpPost($url, Tools::json_encode($data));
132132
if (($result = $this->_decode($result)) === false) {
133-
Tools::log("Get getAuthorizerOption Faild. {$this->errMsg} [$this->errCode]", "ERR-{$this->authorizer_appid}");
133+
Tools::log("Get getAuthorizerOption Faild. {$this->errMsg} [$this->errCode]", "ERR - {$this->authorizer_appid}");
134134
}
135135
return $result;
136136
}
@@ -151,7 +151,7 @@ public function getComponentAccessToken()
151151
$url = self::URL_PREFIX . self::COMPONENT_TOKEN_URL;
152152
$result = Tools::httpPost($url, Tools::json_encode($data));
153153
if (($this->component_access_token = $this->_decode($result, 'component_access_token')) === false) {
154-
Tools::log("Get getComponentAccessToken Faild. {$this->errMsg} [$this->errCode]", "ERR-{$this->authorizer_appid}");
154+
Tools::log("Get getComponentAccessToken Faild. {$this->errMsg} [$this->errCode]", "ERR - {$this->authorizer_appid}");
155155
return false;
156156
}
157157
Tools::setCache($cacheKey, $this->component_access_token, 7200);
@@ -202,7 +202,7 @@ public function getAuthorizationInfo($authorization_code)
202202
$result = Tools::httpPost($url, Tools::json_encode($data));
203203
$authorization_info = $this->_decode($result, 'authorization_info');
204204
if (empty($authorization_info)) {
205-
Tools::log("Get getAuthorizationInfo Faild. {$this->errMsg} [$this->errCode]", "ERR-{$this->authorizer_appid}");
205+
Tools::log("Get getAuthorizationInfo Faild. {$this->errMsg} [$this->errCode]", "ERR - {$this->authorizer_appid}");
206206
return false;
207207
}
208208
$authorization_info['func_info'] = $this->_parseFuncInfo($authorization_info['func_info']);
@@ -241,7 +241,7 @@ public function getWechatInfo($authorizer_appid)
241241
$result = Tools::httpPost($url, Tools::json_encode($data));
242242
$authorizer_info = $this->_decode($result, 'authorizer_info');
243243
if (empty($authorizer_info)) {
244-
Tools::log("Get WechatInfo Faild. {$this->errMsg} [$this->errCode]", "ERR-{$this->authorizer_appid}");
244+
Tools::log("Get WechatInfo Faild. {$this->errMsg} [$this->errCode]", "ERR - {$this->authorizer_appid}");
245245
return false;
246246
}
247247
$author_data = array_merge($authorizer_info, $this->data['authorization_info']);
@@ -271,7 +271,7 @@ public function getAuthorizerOption($authorizer_appid, $option_name)
271271
$url = self::URL_PREFIX . self::GET_AUTHORIZER_OPTION_URL . "?component_access_token={$this->component_access_token}";
272272
$result = Tools::httpPost($url, Tools::json_encode($data));
273273
if (($result = $this->_decode($result)) === false) {
274-
Tools::log("Get getAuthorizerOption Faild. {$this->errMsg} [$this->errCode]", "ERR-{$this->authorizer_appid}");
274+
Tools::log("Get getAuthorizerOption Faild. {$this->errMsg} [$this->errCode]", "ERR - {$this->authorizer_appid}");
275275
}
276276
return $result;
277277
}
@@ -297,7 +297,7 @@ public function setAuthorizerOption($authorizer_appid, $option_name, $option_val
297297
$url = self::URL_PREFIX . self::SET_AUTHORIZER_OPTION_URL . "?component_access_token={$this->component_access_token}";
298298
$result = Tools::httpPost($url, Tools::json_encode($data));
299299
if (($result = $this->_decode($result)) === false) {
300-
Tools::log("Get setAuthorizerOption Faild. {$this->errMsg} [$this->errCode]", "ERR-{$this->authorizer_appid}");
300+
Tools::log("Get setAuthorizerOption Faild. {$this->errMsg} [$this->errCode]", "ERR - {$this->authorizer_appid}");
301301
}
302302
return $result;
303303
}
@@ -333,7 +333,7 @@ public function getPreauthCode()
333333
$result = Tools::httpPost($url, Tools::json_encode($data));
334334
$this->pre_auth_code = $this->_decode($result, 'pre_auth_code');
335335
if (empty($this->pre_auth_code)) {
336-
Tools::log("Get getPreauthCode Faild. {$this->errMsg} [$this->errCode]", "ERR-{$this->authorizer_appid}");
336+
Tools::log("Get getPreauthCode Faild. {$this->errMsg} [$this->errCode]", "ERR - {$this->authorizer_appid}");
337337
}
338338
return $this->pre_auth_code;
339339
}

0 commit comments

Comments
 (0)