diff --git a/kernel-d-log/log-business/src/main/java/cn/stylefeng/roses/kernel/log/business/util/BusinessLogUtil.java b/kernel-d-log/log-business/src/main/java/cn/stylefeng/roses/kernel/log/business/util/BusinessLogUtil.java new file mode 100644 index 000000000..effb1e22b --- /dev/null +++ b/kernel-d-log/log-business/src/main/java/cn/stylefeng/roses/kernel/log/business/util/BusinessLogUtil.java @@ -0,0 +1,50 @@ +package cn.stylefeng.roses.kernel.log.business.util; + +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import cn.stylefeng.roses.kernel.log.business.context.BusinessLogHolder; +import com.alibaba.fastjson2.JSON; + +/** + * 业务日志 + * + * @author fengshuonan + * @since 2023/7/21 18:35 + */ +public class BusinessLogUtil { + + /** + * 设置日志的摘要信息,便于后台搜索 + * + * @author fengshuonan + * @since 2023/7/21 17:30 + */ + public static void setLogTitle(String logTitle) { + if (StrUtil.isEmpty(logTitle)) { + return; + } + BusinessLogHolder.setLogTitle(logTitle); + } + + /** + * 添加日志记录 + * + * @author fengshuonan + * @since 2023/7/21 16:53 + */ + public static void addContent(Object... contentObject) { + if (ObjectUtil.isEmpty(contentObject)) { + return; + } + StringBuilder stringBuffer = new StringBuilder(); + for (Object param : contentObject) { + if (param instanceof String) { + stringBuffer.append(param); + } else { + stringBuffer.append(JSON.toJSONString(param)); + } + } + BusinessLogHolder.addContent(stringBuffer.toString()); + } + +}