拿着我这个改
@Async
public void publishEvent(String level, String id, String data,Integer logType,Integer deviceVersion ) {
HttpServletRequest request = WebUtil.getRequest();
LogPark logPark = new LogPark();
logPark.setLogLevel(level);
logPark.setLogType(logType.toString());
logPark.setDeviceVersion(deviceVersion);
logPark.setLogId(id);
logPark.setLogData(data);
Thread thread = Thread.currentThread();
StackTraceElement[] trace = thread.getStackTrace();
if (trace.length > 3) {
logPark.setMethodClass(trace[3].getClassName());
logPark.setMethodName(trace[3].getMethodName());
}
LogAbstractUtil.addRequestInfoToLog(request, logPark);
// 对于这种参数很长的直接省略
if (request!=null&&"/plateLpr/result".equals(UrlUtil.getPath(request.getRequestURI()))){
logPark.setParams(StringPool.ASTERISK);
}
Map<String, Object> event = new HashMap<>(16);
event.put(EventConstant.EVENT_LOG, logPark);
SpringUtil.publishEvent(new UsualLogEvent(event));
}
blade_log_usual表的数据写入可以看如下文档,如果觉得不够用,可以拓展下blade-starter-log的底层逻辑
扫一扫访问 Blade技术社区 移动端