@Override
public StdioContext getStdioContext() {
final LogContext logContext = LogContext.getLogContext();
final Logger root = logContext.getLogger(CommonAttributes.ROOT_LOGGER_NAME);
StdioContext stdioContext = root.getAttachment(STDIO_CONTEXT_ATTACHMENT_KEY);
if (stdioContext == null) {
stdioContext = StdioContext.create(
new NullInputStream(),
new LoggingOutputStream(logContext.getLogger("stdout"), Level.INFO),
new LoggingOutputStream(logContext.getLogger("stderr"), Level.ERROR)
);
final StdioContext appearing = root.attachIfAbsent(STDIO_CONTEXT_ATTACHMENT_KEY, stdioContext);
if (appearing != null) {
stdioContext = appearing;
}
}
return stdioContext;