Last active
April 23, 2022 17:53
-
-
Save stdmitry/21b16c75f0d9291a26fe932ffbc099eb to your computer and use it in GitHub Desktop.
Java logging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LogHelper { | |
public static <T> Consumer<Signal<T>> info(Logger logger, String logStatement, Object... arguments) { | |
return signal -> { | |
if (signal.isOnNext()) { | |
info(logger, logStatement, signal.getContextView(), arguments); | |
} | |
}; | |
} | |
public static void info(Logger logger,String logStatement, ContextView ctx, Object... arguments) { | |
var requestId = (String) ctx.get("requestId"); | |
try (MDC.MDCCloseable ignored = MDC.putCloseable("requestId", requestId)) { | |
logger.info(logStatement, arguments); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment