Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

自定义 log-record.diff-msg-format 结果错误 #80

Closed
duanluan opened this issue Jul 31, 2023 · 3 comments
Closed

自定义 log-record.diff-msg-format 结果错误 #80

duanluan opened this issue Jul 31, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@duanluan
Copy link
Contributor

duanluan commented Jul 31, 2023

版本:v1.5.1

application.yml:

log-record:
  # Diff 时忽略新对象中 null 值字段,默认为 false
  diff-ignore-new-object-null-value: true
  # Diff 格式
  diff-msg-format: 【${_fieldName}】:【${_oldValue}】->【${_newValue}】
  # Diff 分隔符
  diff-msg-separator: ;

UserController:

@OperationLog(bizId = "#id", bizType = "'user:update'", msg = "'更新用户:' + #_DIFF(#oldObj, #obj)")
public ApiResponse update(@Min(value = 1, message = "参数错误") @PathVariable Long id, @Validated @RequestBody UserUpdateQO obj) {
  User user = userService.getById(id);
  if (user == null) {
    throw new ServiceException("用户不存在");
  }
  LogRecordContext.putVariable("oldObj", user);
  // ……
}

User:

@LogRecordDiffObject(alias = "用户")
public class User {
  @LogRecordDiffField(alias = "用户名")
  private String username;
  // ……
}

UserUpdateQO:

@LogRecordDiffObject
public class UserUpdateQO {
  @LogRecordDiffField(alias = "用户名")
  private String username;
  // ……
}

结果:更新用户:?电话?:?18888888887?->?18888888888?;?昵称?:?234?->?23?;?角色?:?2,1671440885033914373?->?2?

我所有的文件编码都是UTF-8
我试过给diff-msg-format的内容前后加单引号也没用。

@qqxx6661
Copy link
Owner

晚点我看下

@qqxx6661 qqxx6661 added the bug Something isn't working label Aug 3, 2023
@qqxx6661
Copy link
Owner

我复现了你的问题,和你的properties文件编码有关,带中文括号的话就得用UTF-8了

image image image

@duanluan
Copy link
Contributor Author

我复现了你的问题,和你的properties文件编码有关,带中文括号的话就得用UTF-8了

我 IDEA 的“新项目的设置”就是全部都是 UTF-8,我在提 issue 之前也检查过。我又按照你图片里的“”将application.yml将其编码改成 ISO-8859-1 也不行。我再试了下将application.yml改成 UTF-8 的application.properties也不行。

我建了一个最简单的项目,调用http://localhost:8080/a?name=%E5%BC%A0%E4%B8%89测试之后仍然不行。
image
demo.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants