String (@NotNull GradleTestsExecutionConsole executionConsole, @NotNull String text, @NotNull Key<?> processOutputType) { String eventMessage = null; final StringBuilder consoleBuffer = executionConsole.getBuffer(); String trimmedText = text.trim(); if (StringUtil.endsWith(trimmedText, LOG_EOL)) { consoleBuffer.append(StringUtil.trimEnd(trimmedText, LOG_EOL)); return null; } else { if (consoleBuffer.isEmpty()) { if (StringUtil.startsWith(trimmedText, LOG_START) && StringUtil.endsWith(trimmedText, LOG_END)) { eventMessage = text; } else { executionConsole.print(text, ConsoleViewContentType.getConsoleViewType(processOutputType)); return null; } } else { consoleBuffer.append(text); if (trimmedText.isEmpty()) return null; } } if (eventMessage == null) { String bufferText = consoleBuffer.toString().trim(); consoleBuffer.setLength(0); if (!StringUtil.startsWith(bufferText, LOG_START) || !StringUtil.endsWith(bufferText, LOG_END)) { executionConsole.print(bufferText, ConsoleViewContentType.getConsoleViewType(processOutputType)); return null; } eventMessage = bufferText; } assert consoleBuffer.isEmpty(); return eventMessage; }