提交 | 用户 | 时间
|
e7c126
|
1 |
package com.iailab.framework.apilog.core.service; |
H |
2 |
|
|
3 |
import com.iailab.module.infra.api.logger.ApiErrorLogApi; |
|
4 |
import com.iailab.module.infra.api.logger.dto.ApiErrorLogCreateReqDTO; |
|
5 |
import lombok.RequiredArgsConstructor; |
325d2f
|
6 |
import lombok.extern.slf4j.Slf4j; |
e7c126
|
7 |
import org.springframework.scheduling.annotation.Async; |
H |
8 |
|
|
9 |
/** |
|
10 |
* API 错误日志 Framework Service 实现类 |
|
11 |
* |
|
12 |
* 基于 {@link ApiErrorLogApi} 服务,记录错误日志 |
|
13 |
* |
|
14 |
* @author iailab |
|
15 |
*/ |
|
16 |
@RequiredArgsConstructor |
325d2f
|
17 |
@Slf4j |
e7c126
|
18 |
public class ApiErrorLogFrameworkServiceImpl implements ApiErrorLogFrameworkService { |
H |
19 |
|
|
20 |
private final ApiErrorLogApi apiErrorLogApi; |
|
21 |
|
|
22 |
@Override |
|
23 |
@Async |
|
24 |
public void createApiErrorLog(ApiErrorLogCreateReqDTO reqDTO) { |
325d2f
|
25 |
try { |
H |
26 |
apiErrorLogApi.createApiErrorLog(reqDTO); |
|
27 |
} catch (Throwable ex) { |
|
28 |
// 由于 @Async 异步调用,这里打印下日志,更容易跟进 |
|
29 |
log.error("[createApiErrorLog][url({}) log({}) 发生异常]", reqDTO.getRequestUrl(), reqDTO, ex); |
|
30 |
} |
e7c126
|
31 |
} |
H |
32 |
|
|
33 |
} |