@Test void shouldLogInfoAndErrorMessage() { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); PrintStream printStream = new PrintStream(outputStream); TaskListener taskListener = createTaskListener(printStream); Report report = new Report(); report.logInfo(NOT_SHOWN); report.logError(NOT_SHOWN); LogHandler logHandler = new LogHandler(taskListener, LOG_HANDLER_NAME, report); report.logInfo(MESSAGE); report.logError(MESSAGE); logHandler.log(report); assertThat(outputStream.toString()).isEqualTo(String.format( "[%s] [-ERROR-] %s%n" + "[%s] %s%n", LOG_HANDLER_NAME, MESSAGE, LOG_HANDLER_NAME, MESSAGE)); report.logInfo(ADDITIONAL_MESSAGE); report.logError(ADDITIONAL_MESSAGE); logHandler.log(report); assertThat(outputStream.toString()).isEqualTo(String.format( "[%s] [-ERROR-] %s%n" + "[%s] %s%n" + "[%s] [-ERROR-] %s%n" + "[%s] %s%n", LOG_HANDLER_NAME, MESSAGE, LOG_HANDLER_NAME, MESSAGE, LOG_HANDLER_NAME, ADDITIONAL_MESSAGE, LOG_HANDLER_NAME, ADDITIONAL_MESSAGE)); }
public void log(final Report report) { logErrorMessages(report); logInfoMessages(report); }
LogHandler { public void log(final Report report) { logErrorMessages(report); logInfoMessages(report); } }
LogHandler { public void log(final Report report) { logErrorMessages(report); logInfoMessages(report); } LogHandler(final TaskListener listener, final String name);  LogHandler(final TaskListener listener, final String name, final Report report); private  LogHandler(final TaskListener listener, final String name, final int infoPosition,
            final int errorPosition); }
LogHandler { public void log(final Report report) { logErrorMessages(report); logInfoMessages(report); } LogHandler(final TaskListener listener, final String name);  LogHandler(final TaskListener listener, final String name, final Report report); private  LogHandler(final TaskListener listener, final String name, final int infoPosition,
            final int errorPosition); void log(final Report report); @FormatMethod void log(final String format, final Object... args); }
LogHandler { public void log(final Report report) { logErrorMessages(report); logInfoMessages(report); } LogHandler(final TaskListener listener, final String name);  LogHandler(final TaskListener listener, final String name, final Report report); private  LogHandler(final TaskListener listener, final String name, final int infoPosition,
            final int errorPosition); void log(final Report report); @FormatMethod void log(final String format, final Object... args);  }