【优化】统一日志打印格式

pull/22/head
xuyuxiang 2021-01-21 15:09:13 +08:00
parent a7618d81e6
commit 8d41de6c0a
2 changed files with 9 additions and 9 deletions

View File

@ -39,7 +39,7 @@ public class AliyunSmsSender implements SmsSender {
@Override @Override
public void sendSms(String phone, String templateCode, Map<String, Object> params) { public void sendSms(String phone, String templateCode, Map<String, Object> params) {
log.info("开始发送阿里云短信,手机号是:" + phone + ",模板号是:" + templateCode + ",参数是:" + params); log.info(">>> 开始发送阿里云短信,手机号是:" + phone + ",模板号是:" + templateCode + ",参数是:" + params);
// 检验参数是否合法 // 检验参数是否合法
assertSendSmsParams(phone, templateCode, params, aliyunSmsProperties); assertSendSmsParams(phone, templateCode, params, aliyunSmsProperties);
@ -62,7 +62,7 @@ public class AliyunSmsSender implements SmsSender {
errorMessage = smsExceptionEnum.getMessage(); errorMessage = smsExceptionEnum.getMessage();
} }
} }
log.error("发送短信异常code = " + code + ",message = " + errorMessage); log.error(">>> 发送短信异常code = " + code + ",message = " + errorMessage);
throw new AliyunSmsException(code, errorMessage); throw new AliyunSmsException(code, errorMessage);
} }
} }
@ -112,10 +112,10 @@ public class AliyunSmsSender implements SmsSender {
commonResponse = acsClient.getCommonResponse(request); commonResponse = acsClient.getCommonResponse(request);
String data = commonResponse.getData(); String data = commonResponse.getData();
String jsonResult = data.replaceAll("'\'", ""); String jsonResult = data.replaceAll("'\'", "");
log.info("获取到发送短信的响应结果!{}", jsonResult); log.info(">>> 获取到发送短信的响应结果!{}", jsonResult);
return JSON.parseObject(jsonResult); return JSON.parseObject(jsonResult);
} catch (ClientException e) { } catch (ClientException e) {
log.error("初始化阿里云sms异常可能是accessKey和secret错误", e); log.error(">>> 初始化阿里云sms异常可能是accessKey和secret错误", e);
throw new AliyunSmsException(AliyunSmsResultEnum.INIT_SMS_CLIENT_ERROR.getCode(), throw new AliyunSmsException(AliyunSmsResultEnum.INIT_SMS_CLIENT_ERROR.getCode(),
AliyunSmsResultEnum.INIT_SMS_CLIENT_ERROR.getMessage()); AliyunSmsResultEnum.INIT_SMS_CLIENT_ERROR.getMessage());
} }
@ -130,7 +130,7 @@ public class AliyunSmsSender implements SmsSender {
private void assertSendSmsParams(String phoneNumber, String templateCode, Map<String, Object> params, private void assertSendSmsParams(String phoneNumber, String templateCode, Map<String, Object> params,
AliyunSmsProperties aliyunSmsProperties) { AliyunSmsProperties aliyunSmsProperties) {
if (ObjectUtil.hasEmpty(phoneNumber, templateCode, params, aliyunSmsProperties)) { if (ObjectUtil.hasEmpty(phoneNumber, templateCode, params, aliyunSmsProperties)) {
log.error("阿里云短信发送异常!请求参数存在空!"); log.error(">>> 阿里云短信发送异常!请求参数存在空!");
throw new AliyunSmsException(AliyunSmsResultEnum.PARAM_NULL.getCode(), AliyunSmsResultEnum.PARAM_NULL.getMessage()); throw new AliyunSmsException(AliyunSmsResultEnum.PARAM_NULL.getCode(), AliyunSmsResultEnum.PARAM_NULL.getMessage());
} }
} }
@ -146,7 +146,7 @@ public class AliyunSmsSender implements SmsSender {
// 如果是单个签名就用一个签名发 // 如果是单个签名就用一个签名发
if (!signName.contains(",")) { if (!signName.contains(",")) {
log.info("发送短信,签名为:" + signName + ",电话为:" + phone); log.info(">>> 发送短信,签名为:" + signName + ",电话为:" + phone);
return signName; return signName;
} else { } else {
return multiSignManager.getSign(phone, signName); return multiSignManager.getSign(phone, signName);

View File

@ -33,18 +33,18 @@ public class MapBasedMultiSignManager implements MultiSignManager {
Object lastSignName = cacheMap.get(phone); Object lastSignName = cacheMap.get(phone);
if (lastSignName == null) { if (lastSignName == null) {
cacheMap.put(phone, signNames[0]); cacheMap.put(phone, signNames[0]);
log.info("发送短信,签名为:" + signNames[0] + ",电话为:" + phone); log.info(">>> 发送短信,签名为:" + signNames[0] + ",电话为:" + phone);
return signNames[0]; return signNames[0];
} else { } else {
for (String name : signNames) { for (String name : signNames) {
if (!name.equals(lastSignName)) { if (!name.equals(lastSignName)) {
cacheMap.put(phone, name); cacheMap.put(phone, name);
log.info("发送短信,签名为:" + name + ",电话为:" + phone); log.info(">>> 发送短信,签名为:" + name + ",电话为:" + phone);
return name; return name;
} }
} }
cacheMap.put(phone, signNames[0]); cacheMap.put(phone, signNames[0]);
log.info("发送短信,签名为:" + signNames[0] + ",电话为:" + phone); log.info(">>> 发送短信,签名为:" + signNames[0] + ",电话为:" + phone);
return signNames[0]; return signNames[0];
} }
} }