优化日志

This commit is contained in:
wulin 2023-11-22 16:56:32 +08:00
parent 60692f5ff6
commit 36f56b40dd
2 changed files with 5 additions and 12 deletions

View File

@ -27,10 +27,6 @@ public class LogMdcConfiguration {
@PostConstruct
public void contextOperatorHook() {
Hooks.onEachOperator(PRINT_LOG_ID, Operators.lift((r, c) ->{
/*Context ctx = c.currentContext();
if(ctx.hasKey(PRINT_LOG_ID)){
MDC.put(PRINT_LOG_ID, ctx.get(PRINT_LOG_ID));
}*/
return new MdcContextSubscriber(c);
}));
}
@ -69,9 +65,8 @@ public class LogMdcConfiguration {
@Override
public void onNext(T t) {
Context ctx = currentContext();
if(ctx.hasKey(PRINT_LOG_ID)){
MDC.put(PRINT_LOG_ID, ctx.get(PRINT_LOG_ID));
if(currentContext().hasKey(PRINT_LOG_ID)){
MDC.put(PRINT_LOG_ID, currentContext().get(PRINT_LOG_ID));
}
coreSubscriber.onNext(t);
}

View File

@ -26,10 +26,6 @@ public class LogMdcConfiguration {
@PostConstruct
public void contextOperatorHook() {
Hooks.onEachOperator(PRINT_LOG_ID, Operators.lift((r, c) ->{
Context ctx = c.currentContext();
if(ctx.hasKey(PRINT_LOG_ID)){
MDC.put(PRINT_LOG_ID, ctx.get(PRINT_LOG_ID));
}
return new MdcContextSubscriber(c);
}));
}
@ -69,7 +65,9 @@ public class LogMdcConfiguration {
@Override
public void onNext(T t) {
if(coreSubscriber.currentContext().hasKey(PRINT_LOG_ID)){
MDC.put(PRINT_LOG_ID, coreSubscriber.currentContext().get(PRINT_LOG_ID));
}
coreSubscriber.onNext(t);
}