Skip to content

Commit

Permalink
Generalize DI usage
Browse files Browse the repository at this point in the history
This commit ensures that:

* an `InstanceFactory` is created in the Log4j `Provider`,
* the same factory is injected as parameters to all
  the components of the chain `Log4jContextFactory`, `ContextSelector`,
  `LoggerContext` (child), `Configuration` (grand-child).
* `DI.createInstanceFactory` is called only when strictly necessary.
  • Loading branch information
ppkarwasz committed Oct 18, 2024
1 parent eefac99 commit 259a05d
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ String imports() {
+ "import org.apache.logging.log4j.Marker;%n"
+ "import org.apache.logging.log4j.message.Message;%n"
+ "import org.apache.logging.log4j.message.MessageFactory;%n"
+ "import org.apache.logging.log4j.spi.AbstractLogger;%n"
+ "import org.apache.logging.log4j.spi.ExtendedLogger;%n"
+ "import org.apache.logging.log4j.spi.ExtendedLoggerWrapper;%n"
+ "import org.apache.logging.log4j.util.MessageSupplier;%n"
+ "import org.apache.logging.log4j.util.Supplier;%n"
Expand Down Expand Up @@ -91,7 +91,7 @@ String constructor() {
return ""
+ "%n"
+ " private %s(final Logger logger) {%n"
+ " this.logger = new ExtendedLoggerWrapper((AbstractLogger) logger, logger.getName(), "
+ " this.logger = new ExtendedLoggerWrapper((ExtendedLogger) logger, logger.getName(), "
+ "logger.getMessageFactory());%n"
+ " }%n";
// @formatter:on
Expand All @@ -113,7 +113,7 @@ String imports() {
+ "import org.apache.logging.log4j.Marker;%n"
+ "import org.apache.logging.log4j.message.Message;%n"
+ "import org.apache.logging.log4j.message.MessageFactory;%n"
+ "import org.apache.logging.log4j.spi.AbstractLogger;%n"
+ "import org.apache.logging.log4j.spi.ExtendedLogger;%n"
+ "import org.apache.logging.log4j.spi.ExtendedLoggerWrapper;%n"
+ "import org.apache.logging.log4j.util.MessageSupplier;%n"
+ "import org.apache.logging.log4j.util.Supplier;%n"
Expand Down Expand Up @@ -143,7 +143,7 @@ String constructor() {
return ""
+ "%n"
+ " private %s(final Logger logger) {%n"
+ " super((AbstractLogger) logger, logger.getName(), logger.getMessageFactory());%n"
+ " super((ExtendedLogger) logger, logger.getName(), logger.getMessageFactory());%n"
+ " this.logger = this;%n"
+ " }%n";
// @formatter:on
Expand Down

0 comments on commit 259a05d

Please sign in to comment.