package com.qianwen.smartman.common.event;
|
|
import java.util.Map;
|
import org.slf4j.Logger;
|
import org.slf4j.LoggerFactory;
|
import com.qianwen.core.launch.props.BladeProperties;
|
import com.qianwen.core.launch.server.ServerInfo;
|
import com.qianwen.core.log.event.ErrorLogEvent;
|
import com.qianwen.core.log.model.LogError;
|
import com.qianwen.core.log.utils.LogAbstractUtil;
|
import com.qianwen.smartman.modules.system.service.ILogService;
|
import org.springframework.context.event.EventListener;
|
import org.springframework.core.annotation.Order;
|
import org.springframework.scheduling.annotation.Async;
|
|
public class ErrorLogListener {
|
private static final Logger log = LoggerFactory.getLogger(ErrorLogListener.class);
|
private final ILogService logService;
|
private final ServerInfo serverInfo;
|
private final BladeProperties bladeProperties;
|
|
public ErrorLogListener(final ILogService logService, final ServerInfo serverInfo, final BladeProperties bladeProperties) {
|
this.logService = logService;
|
this.serverInfo = serverInfo;
|
this.bladeProperties = bladeProperties;
|
}
|
|
@Async
|
@EventListener({ErrorLogEvent.class})
|
@Order
|
public void saveErrorLog(ErrorLogEvent event) {
|
Map<String, Object> source = (Map) event.getSource();
|
LogError logError = (LogError) source.get("log");
|
LogAbstractUtil.addOtherInfoToLog(logError, this.bladeProperties, this.serverInfo);
|
this.logService.saveErrorLog(logError);
|
}
|
}
|