[Optimize]日志统一格式&优化输出内容-part3(#800)

This commit is contained in:
zengqiao
2022-12-02 15:14:21 +08:00
parent 7a52cf67b0
commit fab41e892f
30 changed files with 84 additions and 84 deletions

View File

@@ -99,13 +99,13 @@ public class ConfigCmdDataParser implements FourLetterWordDataParser<ConfigCmdDa
break;
default:
LOGGER.warn(
"class=ConfigCmdDataParser||method=parseAndInitData||name={}||value={}||msg=data not parsed!",
"method=parseAndInitData||name={}||value={}||msg=data not parsed!",
elem.getKey(), elem.getValue()
);
}
} catch (Exception e) {
LOGGER.error(
"class=ConfigCmdDataParser||method=parseAndInitData||clusterPhyId={}||host={}||port={}||name={}||value={}||errMsg=exception!",
"method=parseAndInitData||clusterPhyId={}||host={}||port={}||name={}||value={}||errMsg=exception!",
clusterPhyId, host, port, elem.getKey(), elem.getValue(), e
);
}

View File

@@ -100,13 +100,13 @@ public class MonitorCmdDataParser implements FourLetterWordDataParser<MonitorCmd
break;
default:
LOGGER.warn(
"class=MonitorCmdDataParser||method=parseAndInitData||name={}||value={}||msg=data not parsed!",
"method=parseAndInitData||name={}||value={}||msg=data not parsed!",
elem.getKey(), elem.getValue()
);
}
} catch (Exception e) {
LOGGER.error(
"class=MonitorCmdDataParser||method=parseAndInitData||clusterPhyId={}||host={}||port={}||name={}||value={}||errMsg=exception!",
"method=parseAndInitData||clusterPhyId={}||host={}||port={}||name={}||value={}||errMsg=exception!",
clusterPhyId, host, port, elem.getKey(), elem.getValue(), e
);
}

View File

@@ -80,13 +80,13 @@ public class ServerCmdDataParser implements FourLetterWordDataParser<ServerCmdDa
break;
default:
LOGGER.warn(
"class=ServerCmdDataParser||method=parseAndInitData||name={}||value={}||msg=data not parsed!",
"method=parseAndInitData||name={}||value={}||msg=data not parsed!",
elem.getKey(), elem.getValue()
);
}
} catch (Exception e) {
LOGGER.error(
"class=ServerCmdDataParser||method=parseAndInitData||clusterPhyId={}||host={}||port={}||name={}||value={}||errMsg=exception!",
"method=parseAndInitData||clusterPhyId={}||host={}||port={}||name={}||value={}||errMsg=exception!",
clusterPhyId, host, port, elem.getKey(), elem.getValue(), e
);
}

View File

@@ -24,7 +24,7 @@ public abstract class BaseExtendFactory {
try {
handler = doGet(classNamePre, clazz);
} catch (NotFindSubclassException e) {
LOGGER.error("class=BaseExtendFactory||method=getByClassNamePer||handleNamePre={}||msg={}", classNamePre,
LOGGER.error("method=getByClassNamePer||handleNamePre={}||msg={}", classNamePre,
e.getMessage());
}
@@ -36,7 +36,7 @@ public abstract class BaseExtendFactory {
try {
beans = SpringTool.getBeansOfType(clazz);
} catch (BeansException e) {
LOGGER.error("class=BaseExtendFactory||method=findFromSpringContext||handleNamePre={}||msg={}",
LOGGER.error("method=findFromSpringContext||handleNamePre={}||msg={}",
classNamePre, e.getMessage());
}

View File

@@ -90,7 +90,7 @@ public class RestTemplateConfig {
try {
traceResponse(request, response, exe, subFlag, beginNano);
} catch (Exception e) {
SYSTEM_LOGGER.warn("class=LogHttpRequestInterceptor||method=intercept||msg={}", e.getMessage());
SYSTEM_LOGGER.warn("method=intercept||msg={}", e.getMessage());
}
throw new ThirdPartRemoteException("rest-template: " + exe.getMessage(), exe,
ResultStatus.HTTP_REQ_ERROR);
@@ -98,7 +98,7 @@ public class RestTemplateConfig {
}
private void traceRequest(HttpRequest request, String subFlag, byte[] body) throws IOException {
REQ_LOGGER.info("class=LogHttpRequestInterceptor||method=traceRequest||remoteRequest||url={}||method={}||headers={}||body={}||subFlag={}",
REQ_LOGGER.info("method=traceRequest||remoteRequest||url={}||method={}||headers={}||body={}||subFlag={}",
request.getURI(), request.getMethod(), JSON.toJSONString(request.getHeaders()), new String(body, "UTF-8"), subFlag);
}
@@ -108,7 +108,7 @@ public class RestTemplateConfig {
StringBuilder inputStringBuilder = new StringBuilder();
if (response == null) {
RESP_LOGGER.warn(
"class=LogHttpRequestInterceptor||method=traceResponse||remoteResponse||code=-1||url={}||text={}||headers={}||body={}||timeCost={}||subFlag={}",
"method=traceResponse||remoteResponse||code=-1||url={}||text={}||headers={}||body={}||timeCost={}||subFlag={}",
url, null, null, null, (System.nanoTime() - nanoTime) / 1000 / 1000, subFlag);
return;
}
@@ -131,7 +131,7 @@ public class RestTemplateConfig {
}
} catch (Exception e) {
RESP_LOGGER.warn(
"class=remoteResponse||code={}||url={}||text={}||headers={}||body={}||error={}||timeCost={}||subFlag={}",
"method=traceResponse||code={}||url={}||text={}||headers={}||body={}||error={}||timeCost={}||subFlag={}",
response.getStatusCode(), url, response.getStatusText(), response.getHeaders(),
inputStringBuilder.toString(), e, (System.nanoTime() - nanoTime) / 1000 / 1000, subFlag);
if (!response.getStatusCode().is2xxSuccessful()) {
@@ -144,12 +144,12 @@ public class RestTemplateConfig {
if (!response.getStatusCode().is2xxSuccessful()) {
if (exception == null) {
RESP_LOGGER.warn(
"class=LogHttpRequestInterceptor||method=traceResponse||remoteResponse||code={}||url={}||text={}||headers={}||body={}||timeCost={}||subFlag={}",
"method=traceResponse||remoteResponse||code={}||url={}||text={}||headers={}||body={}||timeCost={}||subFlag={}",
response.getStatusCode(), url, response.getStatusText(), response.getHeaders(), responseString,
(System.nanoTime() - nanoTime) / 1000 / 1000, subFlag);
} else {
RESP_LOGGER.warn(
"remoteResponse||code={}||url={}||text={}||headers={}||body={}||error={}||timeCost={}||subFlag={}",
"method=traceResponse||remoteResponse||code={}||url={}||text={}||headers={}||body={}||error={}||timeCost={}||subFlag={}",
response.getStatusCode(), url, response.getStatusText(), response.getHeaders(), responseString,
exception, (System.nanoTime() - nanoTime) / 1000 / 1000, subFlag);
}
@@ -158,12 +158,12 @@ public class RestTemplateConfig {
if (exception == null) {
RESP_LOGGER.info(
"class=LogHttpRequestInterceptor||method=traceResponse||remoteResponse||code={}||url={}||text={}||headers={}||responseBody={}||timeCost={}||subFlag={}",
"method=traceResponse||remoteResponse||code={}||url={}||text={}||headers={}||responseBody={}||timeCost={}||subFlag={}",
response.getStatusCode(), url, response.getStatusText(), response.getHeaders(), responseString,
(System.nanoTime() - nanoTime) / 1000 / 1000, subFlag);
} else {
RESP_LOGGER.warn(
"class=LogHttpRequestInterceptor||method=traceResponse||remoteResponse||code={}||url={}||text={}||headers={}||responseBody={}||error={}||timeCost={}||subFlag={}",
"method=traceResponse||remoteResponse||code={}||url={}||text={}||headers={}||responseBody={}||error={}||timeCost={}||subFlag={}",
response.getStatusCode(), url, response.getStatusText(), response.getHeaders(), responseString,
exception, (System.nanoTime() - nanoTime) / 1000 / 1000, subFlag);
}

View File

@@ -131,7 +131,7 @@ public class RestTool {
new HttpEntity<>(null, getJsonContentHeaders(headers)), String.class);
return JSON.parseObject(result.getBody(), resultType);
} catch (Exception e){
LOGGER.error("class=RestTool||method=getForObject||url={}||msg=exception!", url, e);
LOGGER.error("method=getForObject||url={}||msg=exception!", url, e);
}
return null;
@@ -151,7 +151,7 @@ public class RestTool {
new HttpEntity<>(null, headers), String.class);
return JSON.parseObject(result.getBody(), resultType);
} catch (Exception e){
LOGGER.error("class=RestTool||method=getForObject||url={}||msg=exception!", url, e);
LOGGER.error("method=getForObject||url={}||msg=exception!", url, e);
}
return null;

View File

@@ -4,14 +4,14 @@ public enum VersionItemTypeEnum {
/**
* 指标
*/
METRIC_TOPIC(100, "topic_metric"),
METRIC_CLUSTER(101, "cluster_metric"),
METRIC_GROUP(102, "group_metric"),
METRIC_BROKER(103, "broker_metric"),
METRIC_PARTITION(104, "partition_metric"),
METRIC_REPLICATION(105, "replication_metric"),
METRIC_TOPIC(100, "TopicMetric"),
METRIC_CLUSTER(101, "ClusterMetric"),
METRIC_GROUP(102, "GroupMetric"),
METRIC_BROKER(103, "BrokerMetric"),
METRIC_PARTITION(104, "PartitionMetric"),
METRIC_REPLICATION(105, "ReplicaMetric"),
METRIC_ZOOKEEPER(110, "zookeeper_metric"),
METRIC_ZOOKEEPER(110, "ZookeeperMetric"),
/**
* 服务端查询

View File

@@ -61,7 +61,7 @@ public class CommonUtils {
//转换为16进制
return new BigInteger(1, digest).toString(16);
} catch (Exception e) {
LOGGER.error("class=CommonUtils||method=getMD5||msg=获取文件的md5失败:{}", e.getMessage());
LOGGER.error("method=getMD5||msg=获取文件的md5失败:{}", e.getMessage());
}
return null;
}

View File

@@ -210,7 +210,7 @@ public class ConvertUtil {
BeanUtils.copyProperties(srcObj, tgt);
consumer.accept(tgt);
} catch (Exception e) {
LOGGER.warn("class=ConvertUtil||method=obj2Obj||msg={}", e.getMessage());
LOGGER.warn("method=obj2Obj||msg={}", e.getMessage());
}
return tgt;
@@ -236,7 +236,7 @@ public class ConvertUtil {
try {
map.put(field.getName(), field.get(obj));
} catch (IllegalAccessException e) {
LOGGER.warn("class=ConvertUtil||method=Obj2Map||msg={}", e.getMessage(), e);
LOGGER.warn("method=Obj2Map||msg={}", e.getMessage(), e);
}
}
return map;
@@ -256,7 +256,7 @@ public class ConvertUtil {
field.set(obj, map.get(field.getName()));
}
} catch (Exception e) {
LOGGER.warn("class=ConvertUtil||method=map2Obj||msg={}", e.getMessage(), e);
LOGGER.warn("method=map2Obj||msg={}", e.getMessage(), e);
}
return obj;

View File

@@ -64,7 +64,7 @@ public class FutureNoWaitUtil<T> {
while (true) {
FutureTaskDelayQueueData<T> data = null;
try {
LOGGER.debug("class=FutureNoWaitUtil||method=runCheck||delayQueueSize={}", delayQueueData.size());
LOGGER.debug("method=runCheck||delayQueueSize={}", delayQueueData.size());
while (true) {
data = delayQueueData.take();
@@ -81,7 +81,7 @@ public class FutureNoWaitUtil<T> {
// 停1000ms
Thread.sleep(1000);
} catch (Exception e) {
LOGGER.error("class=FutureNoWaitUtil||method=runCheck||taskName={}||errMsg=exception!", data == null? "": data.getTaskName(), e);
LOGGER.error("method=runCheck||taskName={}||errMsg=exception!", data == null? "": data.getTaskName(), e);
}
}
}

View File

@@ -123,11 +123,11 @@ public class FutureWaitUtil<T> {
}
// 达到超时时间,但是任务未完成,则打印日志并强制取消
LOGGER.error("class=FutureUtil||method=waitExecute||taskName={}||msg=cancel task", queueData.getTaskName());
LOGGER.error("method=waitExecute||taskName={}||msg=cancel task", queueData.getTaskName());
queueData.getFutureTask().cancel(true);
} catch (Exception e) {
LOGGER.error("class=FutureUtil||method=waitExecute||msg=exception", e);
LOGGER.error("method=waitExecute||msg=exception", e);
}
}
@@ -155,7 +155,7 @@ public class FutureWaitUtil<T> {
return queueData.getFutureTask().get(stepWaitTimeUnitMs, TimeUnit.MILLISECONDS);
} catch (Exception e) {
// 达到超时时间,但是任务未完成,则打印日志并强制取消
LOGGER.error("class=FutureUtil||method=stepWaitResult||taskName={}||errMsg=exception", queueData.getTaskName(), e);
LOGGER.error("method=stepWaitResult||taskName={}||errMsg=exception", queueData.getTaskName(), e);
}
return null;

View File

@@ -163,7 +163,7 @@ public class PaginationMetricsUtil {
try {
Field defaultField = FieldUtils.getField(allDataList.get(0).getClass(), defaultSortField, true);
if(ValidateUtils.anyNull(defaultField)) {
log.debug("class=PaginationMetricsUtil||method=sortMetrics||className={}||metricName={}||defaultFieldName={}||metricSortType={}||msg=default field not exist.",
log.debug("method=sortMetrics||className={}||metricName={}||defaultFieldName={}||metricSortType={}||msg=default field not exist.",
allDataList.get(0).getClass().getSimpleName(), metricName, defaultSortField, sortType);
// 字段不存在,则排序失效,直接返回
@@ -172,7 +172,7 @@ public class PaginationMetricsUtil {
Collections.sort(allDataList, (a1, a2) -> sortMetricsObject(a1, a2, metricName, defaultField));
} catch (Exception e) {
log.debug("class=PaginationMetricsUtil||method=sortMetrics||className={}||metricName={}||defaultFieldName={}||metricSortType={}||errMsg=exception.",
log.debug("method=sortMetrics||className={}||metricName={}||defaultFieldName={}||metricSortType={}||errMsg=exception.",
allDataList.get(0).getClass().getSimpleName(), metricName, defaultSortField, sortType, e);
}
@@ -214,7 +214,7 @@ public class PaginationMetricsUtil {
return 0;
} catch (Exception e) {
log.debug("class=PaginationMetricsUtil||method=sortMetricsObject||metricsA={}||metricsB={}||metricName={}||defaultFieldName={}||errMsg=exception.",
log.debug("method=sortMetricsObject||metricsA={}||metricsB={}||metricName={}||defaultFieldName={}||errMsg=exception.",
a1, a2, metricName, defaultField.getName(), e);
}

View File

@@ -94,12 +94,12 @@ public class RetryExecutor {
}
} catch (Exception e) {
if (!handler.needRetry(e) || tryCount == retryCount) {
LOGGER.warn("class=RetryExecutor||method=execute||errMsg={}||handlerName={}||tryCount={}",
LOGGER.warn("method=execute||errMsg={}||handlerName={}||tryCount={}",
e.getMessage(), name, tryCount, e);
throw e;
}
LOGGER.warn("class=RetryExecutor||method=execute||errMsg={}||handlerName={}||tryCount={}||maxTryCount={}",
LOGGER.warn("method=execute||errMsg={}||handlerName={}||tryCount={}||maxTryCount={}",
e.getMessage(), name, tryCount,retryCount);
}
} while (tryCount++ < retryCount);

View File

@@ -56,7 +56,7 @@ public class FourLetterWordUtil {
return Result.buildSuc(dataParser.parseAndInitData(clusterPhyId, host, port, cmdData));
} catch (Exception e) {
LOGGER.error(
"class=FourLetterWordUtil||method=executeFourLetterCmd||clusterPhyId={}||host={}||port={}||cmd={}||secure={}||timeout={}||errMsg=exception!",
"method=executeFourLetterCmd||clusterPhyId={}||host={}||port={}||cmd={}||secure={}||timeout={}||errMsg=exception!",
clusterPhyId, host, port, dataParser.getCmd(), secure, timeout, e
);
@@ -124,7 +124,7 @@ public class FourLetterWordUtil {
outputStream.close();
} catch (IOException e) {
LOGGER.error(
"class=FourLetterWordUtil||method=send4LetterWord||clusterPhyId={}||host={}||port={}||cmd={}||secure={}||timeout={}||errMsg=exception!",
"method=send4LetterWord||clusterPhyId={}||host={}||port={}||cmd={}||secure={}||timeout={}||errMsg=exception!",
host, port, cmd, secure, timeout, e
);
}
@@ -135,7 +135,7 @@ public class FourLetterWordUtil {
bufferedReader.close();
} catch (IOException e) {
LOGGER.error(
"class=FourLetterWordUtil||method=send4LetterWord||host={}||port={}||cmd={}||secure={}||timeout={}||errMsg=exception!",
"method=send4LetterWord||host={}||port={}||cmd={}||secure={}||timeout={}||errMsg=exception!",
host, port, cmd, secure, timeout, e
);
}
@@ -146,7 +146,7 @@ public class FourLetterWordUtil {
socket.close();
} catch (IOException e) {
LOGGER.error(
"class=FourLetterWordUtil||method=send4LetterWord||host={}||port={}||cmd={}||secure={}||timeout={}||errMsg=exception!",
"method=send4LetterWord||host={}||port={}||cmd={}||secure={}||timeout={}||errMsg=exception!",
host, port, cmd, secure, timeout, e
);
}