Skip to content

Commit

Permalink
remove internal access
Browse files Browse the repository at this point in the history
  • Loading branch information
InkerBot committed Jun 25, 2024
1 parent d34796a commit 04b312a
Showing 1 changed file with 1 addition and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,13 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.spi.AbstractLoggerAdapter;
import org.apache.logging.log4j.spi.LoggerContext;
import org.apache.logging.log4j.status.StatusLogger;
import org.apache.logging.log4j.util.StackLocatorUtil;
import org.inksnow.cputil.logger.AuroraLogger;
import org.slf4j.ILoggerFactory;
import org.slf4j.Logger;

import java.util.function.Predicate;

/**
* Log4j implementation of SLF4J ILoggerFactory interface.
*/
public class Log4j2LoggerFactory extends AbstractLoggerAdapter<Logger> implements ILoggerFactory {

private static final StatusLogger LOGGER = StatusLogger.getLogger();
private static final Predicate<Class<?>> CALLER_PREDICATE = clazz ->
!AbstractLoggerAdapter.class.equals(clazz) && !clazz.getName().startsWith(AuroraLogger.SLF4J_PACKAGE_NAME);

@Override
protected Logger newLogger(final String name, final LoggerContext context) {
final String key = Logger.ROOT_LOGGER_NAME.equals(name) ? LogManager.ROOT_LOGGER_NAME : name;
Expand All @@ -28,10 +18,6 @@ protected Logger newLogger(final String name, final LoggerContext context) {

@Override
protected LoggerContext getContext() {
final Class<?> anchor = LogManager.getFactory().isClassLoaderDependent()
? StackLocatorUtil.getCallerClass(Log4j2LoggerFactory.class, CALLER_PREDICATE)
: null;
LOGGER.trace("Log4jLoggerFactory.getContext() found anchor {}", anchor);
return anchor == null ? LogManager.getContext(false) : getContext(anchor);
return LogManager.getContext(false);
}
}

0 comments on commit 04b312a

Please sign in to comment.