Merge remote-tracking branch 'pmc/blackr_dev' into leng_dev

# Conflicts:
#	pigx-common/pigx-common-log/src/main/java/com/pig4cloud/pigx/common/log/aspect/SysLogAspect.java
This commit is contained in:
lbw committed 2022-05-22 16:17:05 +08:00
commit b0ea406130
2 files changed
+16 -3

No files matched your search

@@ -34,6 +34,12 @@ public @interface SysLog {
* 描述
* @return {String}
*/
String value();
String value() default "";
/**
* spel 表达式
* @return 日志描述
*/
String expression() default "";
}
@@ -58,11 +58,18 @@ public class SysLogAspect {
log.debug("[类名]:{},[方法]:{}", strClassName, strMethodName);
String value = sysLog.value();
if (StrUtil.contains(value, "#")) {
String expression = sysLog.expression();
// 当前表达式存在 SPEL,会覆盖 value 的值
if (StrUtil.isNotBlank(expression)) {
// 解析SPEL
MethodSignature signature = (MethodSignature) point.getSignature();
EvaluationContext context = SysLogUtils.getContext(point.getArgs(), signature.getMethod());
value = SysLogUtils.getValue(context, value, String.class);
try {
value = SysLogUtils.getValue(context, expression, String.class);
} catch (Exception e) {
// SPEL 表达式异常,则获取 value 的值
log.error("@SysLog 解析SPEL {} 异常", expression);
}
}
SysLogDTO logDTO = SysLogUtils.getSysLog();