Skip to content

Commit

Permalink
fix SLF4J-511 for j.u.l
Browse files Browse the repository at this point in the history
  • Loading branch information
ceki committed Aug 10, 2021
1 parent a739d54 commit 2f1ccdd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Expand Up @@ -37,6 +37,7 @@
import org.slf4j.helpers.MessageFormatter;
import org.slf4j.helpers.NormalizedParameters;
import org.slf4j.helpers.SubstituteLogger;
import org.slf4j.spi.DefaultLoggingEventBuilder;
import org.slf4j.spi.LocationAwareLogger;

/**
Expand Down Expand Up @@ -220,8 +221,9 @@ final private void fillCallerData(String callerFQCN, LogRecord record) {
static String SUPER = LegacyAbstractLogger.class.getName();
static String SUPER_OF_SUPER = AbstractLogger.class.getName();
static String SUBSTITUE = SubstituteLogger.class.getName();

static String BARRIER_CLASSES[] = new String[] { SUPER_OF_SUPER, SUPER, SELF, SUBSTITUE };
static String FLUENT = DefaultLoggingEventBuilder.class.getName();

static String BARRIER_CLASSES[] = new String[] { SUPER_OF_SUPER, SUPER, SELF, SUBSTITUE, FLUENT };

private boolean barrierMatch(String callerFQCN, String candidateClassName) {
if (candidateClassName.equals(callerFQCN))
Expand Down
17 changes: 16 additions & 1 deletion slf4j-jdk14/src/test/java/org/slf4j/issue/CallerInfoTest.java
Expand Up @@ -58,9 +58,24 @@ public void testCallerInfo() {
assertEquals(1, recordList.size());

LogRecord logRecod = recordList.get(0);
assertEquals(CallerInfoTest.class.getName(), logRecod.getSourceClassName());
assertEquals(this.getClass().getName(), logRecod.getSourceClassName());
}

@Test
public void testCallerInfoWithFluentAPI() {
Logger logger = LoggerFactory.getLogger("bla");
logger.atDebug().log("hello");

List<LogRecord> recordList = listHandler.recordList;

assertEquals(1, recordList.size());

LogRecord logRecod = recordList.get(0);
assertEquals(this.getClass().getName(), logRecod.getSourceClassName());
}



@Test
public void testPostInitializationCallerInfoWithSubstituteLogger() {
Logger logger = LoggerFactory.getLogger("bla");
Expand Down

0 comments on commit 2f1ccdd

Please sign in to comment.