mouzt / mzt-biz-log

支持Springboot,基于注解的可使用变量、可以自定义函数的通用操作日志组件
Apache License 2.0
2.06k stars 483 forks source link

successCondition 不生效 #113

Closed Easy-Easy-Easy closed 1 year ago

Easy-Easy-Easy commented 1 year ago

@LogRecord(type = "媒体数据", subType = "删除", bizNo = "{{#oldData.graphId}}_{{#oldData.entityId}}", successCondition = "{{#myCondition==200}}", success = "删除媒体数据,id为:{{#id}}", fail = "操作失败:{{#_errorMsg}}") public AjaxResult remove(@PathVariable Long id) { GraphRelationData graphRelationData = Optional.ofNullable(graphRelationDataService.getById(id)).orElse(new GraphRelationData()); LogRecordContext.putVariable("oldData", graphRelationData); LogRecordContext.putVariable("myCondition", 500); return toAjax(graphRelationDataService.removeById(id)); }

myCondition 设置为500的时候,fail不会被执行

wulangcode commented 1 year ago

你的方法抛出异常了吗? 你的表达式抛出异常时才会记录,或者你修改fail的文案,{{#_errorMsg}}是系统预留记录异常的