示例: @SLog(tag = "添加角色", msg = "角色名称:${args[1].name}")
如何记录操作 成功或失败
扩展这个吗
protected void doLog(String t, InterceptorChain chain, Throwable e) {
String _msg = null;
if (msg.hasKey()) {
Context ctx = Lang.context();
ctx.set("args", chain.getArgs());
ctx.set("return", chain.getReturn());
Context _ctx = Lang.context();
for (String key : msg.keys()) {
_ctx.set(key, els.get(key).eval(ctx));
}
_msg = msg.render(_ctx).toString();
} else {
_msg = msg.getOrginalString();
}
SysLog sysLog = SysLog.c(t, tag, _msg, source);
if (sLogService == null)
sLogService = ioc.get(SLogService.class);
if (async)
sLogService.async(sysLog);
else
sLogService.sync(sysLog);
}
恩,是的,我改造了一下原来的@SLog,你参考一下吧
https://github.com/wendal/nutz-book-project/commit/359cdfc188481c02e23d2d7467e84dda7f321880
@qq_a930202f 已经提炼为插件了 https://github.com/nutzam/nutzmore/tree/master/nutz-plugins-slog