Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ public static Logger getLogger(String dockerImageName) {
abbreviatedName = dockerImageName;
}

if ("UTF-8".equals(System.getProperty("file.encoding"))) {
return LoggerFactory.getLogger("\uD83D\uDC33 [" + abbreviatedName + "]");
} else {
return LoggerFactory.getLogger("docker[" + abbreviatedName + "]");
}
return LoggerFactory.getLogger("org.testcontainers.docker." + abbreviatedName);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return LoggerFactory.getLogger("org.testcontainers.docker." + abbreviatedName);
return LoggerFactory.getLogger("tc." + abbreviatedName);

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.testcontainers.utility;

import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.read.ListAppender;
import org.junit.Test;

import static org.assertj.core.api.Assertions.assertThat;

public class DockerLoggerFactoryTest {

private static final Logger LOGGER = (Logger) DockerLoggerFactory.getLogger("dockerImageName");

@Test
public void debugIsNotSwallowedForContainerLogs() {
// Arrange
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Arrange

ListAppender<ILoggingEvent> listAppender = new ListAppender<>();
listAppender.start();
LOGGER.addAppender(listAppender);

// Act
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Act

LOGGER.debug("some text");

// Assert
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Assert

assertThat(listAppender.list).withFailMessage("Log message has been swallowed").hasSize(1);

ILoggingEvent event = listAppender.list.get(0);

assertThat(event.getFormattedMessage()).isEqualTo("some text");
assertThat(event.getLevel()).isEqualTo(Level.DEBUG);
assertThat(event.getLoggerName()).startsWith("org.testcontainers.docker");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assertThat(event.getLoggerName()).startsWith("org.testcontainers.docker");
assertThat(event.getLoggerName()).startsWith("tc");

}
}
2 changes: 1 addition & 1 deletion modules/orientdb/src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
<logger name="org.testcontainers" level="DEBUG"/>
<logger name="org.testcontainers.shaded" level="WARN"/>

</configuration>
</configuration>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we rollback this, please?