vy opened a new pull request, #2249: URL: https://github.com/apache/logging-log4j2/pull/2249
Motivated by #2204 and making `log4j-api-2.x` adaptable by Log4j 3, this work revamps the `StatusLogger` to make it self-contained and testable. Noteworthy changes are as follows: ### Simplifications and improvements for self-contained implementation * Dependencies on `PropertiesUtil` and `LoaderUtil` are eliminated. To do so, simple system property and resource from classpath readers are implemented. See the new `StatusLogger.Config` class. * Dependency on `SimpleLogger` is eliminated. The default listener is fixed to a `StatusConsoleListener` which dumps `StatusData#getFormattedStatus()` output to a `PrintStream`. * **[behavioural change]** `StatusConfiguration` does not create a new `StatusListener` each time anymore. That is, there will not be a dedicated `StatusConsoleListener` for every each `LoggerContext`. Existing behaviour was already problematic: * Each `StatusConfiguration` created was resetting the `StatusLogger` listener level (hence, last one always wins) * Created `StatusConsoleListener`s weren't cleaned up * Even though there was a dedicated listener for each `LoggerContext`, there is always a single `StatusLogger`, defeating the purpose of per-`LoggerContext` listeners * Hence, we embraced a simpler model: There is one default `StatusConsoleListener` for the `StatusLogger` singleton. If user overrides the `StatusLogger` configuration in a `log4j2.xml`, last read configuration will be the effective one. * Several `StatusLogger` javadocs are rewritten. * `LowLevelLogUtil` is removed. * `AbstractLogger` doesn't act on `log4j2.messageFactory` and `log4j2.flowMessageFactory` properties anymore; its message and flow message factories are fixed to `ParameterizedMessageFactory` and `DefaultFlowMessageFactory`, respectively. This was necessary to avoid cyclic instantiation: `PropertiesUtil` is using `StatusLogger`, which extends `AbstractLogger`, which indirectly reaches back to `PropertiesUtil` for these two functionalities removed. ### Testing-related changes * `StatusLogger` is made extendable (to enable mocking/spying) * `StatusLogger` static instance is made replaceable (to enable substituting the implementation for tests) * Leveraging these, `@UsingStatusLoggerMock` introduced ### TODO * Introduce `log4j2.messageFactory` and `log4j2.flowMessageFactory` properties back * Update docs * Fix last remaining failing tests (already fixed some) * Check if there are any refactoring opportunities for `@UsingStatusListener` ### Review kit 1. Start with reviewing changes in `o.a.l.l.status` package: `StatusLogger`, `StatusData`, `StatusConsoleListener`, etc. 2. Review `StatusConfiguration` 3. Review `o.a.l.l.test.junit.StatusLoggerMockExtension` to see testing conveniences 4. Review the rest -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@logging.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org