Skip to content

Commit

Permalink
Logging fixes.
Browse files Browse the repository at this point in the history
We were missing some logs because of how setLogging worked.
  • Loading branch information
prdoyle committed Feb 8, 2024
1 parent 471b7f6 commit 9aee832
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ private R callDownstreamInitialRoot(Type rootType) {
*/
private void refurbishTransaction() throws IOException {
collection.ensureTransactionStarted();
LOGGER.debug("Refurbishing to {}", driverSettings.preferredDatabaseFormat());
try {
// Design note: this operation shouldn't do any special coordination with
// the receiver/listener system, because other replicas won't.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ void runTearDown(TestInfo testInfo) {
// We'd like to use SLF4J's "Level" but that doesn't support OFF
public void setLogging(Level level, Logger logger) {
ch.qos.logback.classic.Logger logbackLogger = (ch.qos.logback.classic.Logger) logger;
if (Level.DEBUG.isGreaterOrEqual(logbackLogger.getEffectiveLevel())) {
// Note: in logback, a "greater" level is less verbose. So if DEBUG is greater or equal to
// the current effective level, it means the user has asked for DEBUG logs (or more),
// assuming the logback.xml settings specify INFO by default.
if (!ALREADY_WARNED.getAndSet(true)) {
LOGGER.warn("Logging level is {}; ignoring the recommended setting from the testcase itself", logbackLogger.getEffectiveLevel());
}
return;
}
Level originalLevel = logbackLogger.getLevel();
if (originalLevel == null) {
tearDownActions.addFirst(()->logbackLogger.setLevel(originalLevel));
Expand Down Expand Up @@ -170,6 +179,9 @@ public interface Refs {
@ReferencePath("/values/string") Reference<String> valuesString();
}

/**
* One warning that we're ignoring logging settings from the testcase is enough.
*/
private static final AtomicBoolean ALREADY_WARNED = new AtomicBoolean(false);
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractMongoDriverTest.class);
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void pairwise_readCompatible() throws Exception {

@ParametersByName(singleInvocationIndex = 5)
void pairwise_writeCompatible() throws Exception {
fromHelper.setLogging(Level.ERROR, SequoiaFormatDriver.class, PandoFormatDriver.class);
fromHelper.setLogging(Level.ERROR, SequoiaFormatDriver.class, PandoFormatDriver.class, ChangeReceiver.class);

LOGGER.debug("Create fromBosk [{}]", fromHelper.name);
Bosk<TestEntity> fromBosk = newBosk(fromHelper);
Expand Down

0 comments on commit 9aee832

Please sign in to comment.