feat(log): 添加traceId
This commit is contained in:
+5
@@ -25,6 +25,7 @@
|
||||
*/
|
||||
package org.springblade.core.context;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.slf4j.MDC;
|
||||
import org.springblade.core.tool.utils.ThreadLocalUtil;
|
||||
import org.springframework.lang.Nullable;
|
||||
@@ -37,6 +38,7 @@ import java.util.concurrent.Callable;
|
||||
*
|
||||
* @author L.cm
|
||||
*/
|
||||
@Slf4j
|
||||
public class BladeCallableWrapper<V> implements Callable<V> {
|
||||
private final Callable<V> delegate;
|
||||
private final Map<String, Object> tlMap;
|
||||
@@ -62,6 +64,9 @@ public class BladeCallableWrapper<V> implements Callable<V> {
|
||||
}
|
||||
try {
|
||||
return delegate.call();
|
||||
} catch (Exception e) {
|
||||
log.error("异步任务执行异常", e);
|
||||
throw e;
|
||||
} finally {
|
||||
tlMap.clear();
|
||||
if (mdcMap != null) {
|
||||
|
||||
+5
@@ -25,6 +25,7 @@
|
||||
*/
|
||||
package org.springblade.core.context;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.slf4j.MDC;
|
||||
import org.springblade.core.tool.utils.ThreadLocalUtil;
|
||||
import org.springframework.lang.Nullable;
|
||||
@@ -36,6 +37,7 @@ import java.util.Map;
|
||||
*
|
||||
* @author L.cm
|
||||
*/
|
||||
@Slf4j
|
||||
public class BladeRunnableWrapper implements Runnable {
|
||||
private final Runnable delegate;
|
||||
private final Map<String, Object> tlMap;
|
||||
@@ -61,6 +63,9 @@ public class BladeRunnableWrapper implements Runnable {
|
||||
}
|
||||
try {
|
||||
delegate.run();
|
||||
} catch (Exception e) {
|
||||
log.error("异步任务执行异常", e);
|
||||
throw e;
|
||||
} finally {
|
||||
tlMap.clear();
|
||||
if (mdcMap != null) {
|
||||
|
||||
Reference in New Issue
Block a user