加入参数控制json超过一定长度不打印

This commit is contained in:
wangxin
2019-06-28 16:01:44 +08:00
parent 0edcf7162f
commit 2155998f13
5 changed files with 27 additions and 9 deletions

View File

@@ -8,6 +8,10 @@ import java.util.regex.Pattern;
import com.google.gson.GsonBuilder;
public final class Constants {
/**
* json打印长度
*/
public static Integer JSON_PRINT_LENTH=Configurations.getIntProperty("json_print_length", 100000);
/**
* obj group list group type
*/

View File

@@ -438,7 +438,11 @@ public class SchedulerTaskUtil {
maatBean.setVersion(Constants.MAAT_VERSION);
maatBean.setOpAction(Constants.INSERT_ACTION);
String json=BaseService.gsonToJson(maatBean);
logger.info("定时任务修改NTC/PROXY策略的MAAT配置内容"+json);
if(json.length()<Constants.JSON_PRINT_LENTH){
logger.info("定时任务修改NTC/PROXY策略的MAAT配置内容"+json);
}else{
logger.info("定时任务修改NTC/PROXY策略的MAAT配置内容超过"+Constants.JSON_PRINT_LENTH+",不打印");
}
//调用服务接口修改配置内容与状态
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
if(result!=null){

View File

@@ -1924,7 +1924,7 @@ public abstract class BaseService {
maatBean.setOpAction(Constants.INSERT_ACTION);
// 调用服务接口下发配置数据
String json = BaseService.gsonToJson(maatBean);
if(configCompileList.size()>10) {
if(json.length()>Constants.JSON_PRINT_LENTH) {
logger.info("APP主题网站配置下发配置参数" + configCompileList.size());
}else {
logger.info("APP主题网站配置下发配置参数" + json);
@@ -1988,7 +1988,7 @@ public abstract class BaseService {
maatBean.setOpAction(Constants.INSERT_ACTION);
// 调用服务接口下发配置数据
String json = BaseService.gsonToJson(maatBean);
if(configCompileList.size()>10) {
if(json.length()>Constants.JSON_PRINT_LENTH) {
logger.info("APP Feature增强字符串配置下发配置条数" + configCompileList.size());
}else {
logger.info("APP Feature增强字符串配置下发配置参数" + json);
@@ -2401,7 +2401,7 @@ public abstract class BaseService {
maatBean.setOpAction(Constants.INSERT_ACTION);
// 调用服务接口下发配置数据
String json = BaseService.gsonToJson(maatBean);
if(configCompileList.size()>10) {
if(json.length()>Constants.JSON_PRINT_LENTH) {
logger.info("APP策略 配置下发配置条数:" + configCompileList.size());
}else {
logger.info("APP策略 配置下发配置参数:" + json);
@@ -2609,7 +2609,7 @@ public abstract class BaseService {
start=System.currentTimeMillis();
// 调用服务接口下发配置数据
String json = BaseService.gsonToJson(maatBean);
if(configCompileList.size()>10) {
if(json.length()>Constants.JSON_PRINT_LENTH) {
logger.info("IP 配置下发配置条数:" + configCompileList.size());
}else {
logger.info("IP 配置下发配置参数:" + json);
@@ -2756,7 +2756,7 @@ public abstract class BaseService {
start=System.currentTimeMillis();
// 调用服务接口下发配置数据
String json = BaseService.gsonToJson(maatBean);
if(configCompileList.size()>10) {
if(json.length()>Constants.JSON_PRINT_LENTH) {
logger.info("字符串配置下发配置条数:" + configCompileList.size());
}else {
logger.info("字符串配置下发配置参数:" + json);
@@ -2886,7 +2886,7 @@ public abstract class BaseService {
maatBean.setOpAction(Constants.INSERT_ACTION);
// 调用服务接口下发配置数据
String json = BaseService.gsonToJson(maatBean);
if(configCompileList.size()>10) {
if(json.length()>Constants.JSON_PRINT_LENTH) {
logger.info("增强字符串配置下发配置条数:" + configCompileList.size());
}else {
logger.info("增强字符串配置下发配置参数:" + json);

View File

@@ -455,7 +455,11 @@ public class ObjectGroupService extends BaseService {
maatBean.setOpAction(opAction);
//调用服务接口下发配置数据
String json=gsonToJson(maatBean);
logger.info("策略对象组下发配置参数:"+json);
if(json.length()<Constants.JSON_PRINT_LENTH){
logger.info("策略对象组下发配置参数:"+json);
}else{
logger.info("策略对象组下发配置内容超过"+Constants.JSON_PRINT_LENTH+",不打印");
}
//调用服务接口下发配置
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
logger.info("策略对象组下发响应信息:"+result.getMsg());
@@ -472,7 +476,11 @@ public class ObjectGroupService extends BaseService {
maatBean.setOpAction(Constants.UPDATE_ACTION);
//调用服务接口取消配置
String json=gsonToJson(maatBean);
logger.info("策略对象组下发配置参数:"+json);
if(json.length()<Constants.JSON_PRINT_LENTH){
logger.info("策略对象组下发配置参数:"+json);
}else{
logger.info("策略对象组下发配置内容超过"+Constants.JSON_PRINT_LENTH+",不打印");
}
//调用服务接口下发配置
ToMaatResult result = ConfigServiceUtil.put(json,1);
logger.info("策略对象组取消配置响应信息:"+result.getMsg());

View File

@@ -546,3 +546,5 @@ ip_obj_group_type=5
url_obj_group_type=7
subid_obj_group_type=9
domain_obj_group_type=8
#not print json if it is larger than this param
json_print_length=10000000