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.UsualLogEvent;
|
import com.qianwen.core.log.model.LogUsual;
|
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 UsualLogListener {
|
private static final Logger log = LoggerFactory.getLogger(UsualLogListener.class);
|
private final ILogService logService;
|
private final ServerInfo serverInfo;
|
private final BladeProperties bladeProperties;
|
|
public UsualLogListener(final ILogService logService, final ServerInfo serverInfo, final BladeProperties bladeProperties) {
|
this.logService = logService;
|
this.serverInfo = serverInfo;
|
this.bladeProperties = bladeProperties;
|
}
|
|
@Async
|
@EventListener({UsualLogEvent.class})
|
@Order
|
public void saveUsualLog(UsualLogEvent event) {
|
Map<String, Object> source = (Map) event.getSource();
|
LogUsual logUsual = (LogUsual) source.get("log");
|
LogAbstractUtil.addOtherInfoToLog(logUsual, this.bladeProperties, this.serverInfo);
|
this.logService.saveUsualLog(logUsual);
|
}
|
}
|