Dev#6
Conversation
Introduce the microsphere-logging-log4j2 module to provide Log4j2 integration. Adds Log4j2Logger (adapter wrapping org.apache.logging.log4j.Logger), Log4j2LoggerFactory (registered via META-INF/services), and unit tests for the factory and logger behavior. Also updates README to list the new module. The factory sets its priority to NORMAL_PRIORITY - 5.
Add a lightweight TestingLogging implementation for tests and update test-suite to use it. Tests modified: LoggingMXBeanAdapterTest now initializes TestingLogging with sample logger levels and iterates over its supported logging levels; LoggingMXBeanRegistrarTest expectation updated to reflect the TestingLogging MBean name. Also update the service loader resource to register io.microsphere.logging.TestingLogging instead of the previous StandardLogging.
Introduce a new microsphere-logging-jdk module (pom, SPI registration, and tests) and move StandardLogging -> JDKLogging. Resolve logging levels via DefaultLoggingLevelsResolver.INSTANCE and add PRIORITY/ALL_LEVELS constants for JDK, Log4j2 and Logback; implement getPriority() to return those constants. Update parent pom and dependency management to include the new module, remove the old core test, and adjust README module list and small docs cleanup. Also update Log4j2/Logback factories and tests to use the new PRIORITY/ALL_LEVELS constants.
Replace dynamic resolution of logging levels with the ALL_LEVELS constant in getSupportedLoggingLevels. Update tests to import ALL_LEVELS, add a test for constant values (PRIORITY and ALL_LEVELS/LOGBACK_LEVELS), and remove redundant assertions from testGetPriority. This simplifies level retrieval and centralizes level definitions for consistency.
Move the assertEquals(10, PRIORITY) check from testGetPriority() to testConstants() to centralize constant verification. Removes the duplicate assertion from testGetPriority(), keeping the test focused on instance behavior.
Add unit tests in Log4j2LoggingTest to verify PRIORITY and ALL_LEVELS: assert PRIORITY equals -5 and ALL_LEVELS equals LOG4J2_LEVELS. Also add a test confirming logging.getPriority() returns PRIORITY. Added static imports for PRIORITY and ALL_LEVELS.
Change test setup to obtain the Logging implementation via ServiceLoader (loadFirstService(Logging.class)) instead of instantiating Log4j2Logging directly. Added imports for Logging and the service loader util, and cast the result to Log4j2Logging in setUp(). Removed the test resources META-INF/services/io.microsphere.logging.Logging file so the SPI resolution uses the real available provider(s) rather than the test-local registration.
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
🤖 Augment PR SummarySummary: This PR modularizes backend implementations and adds first-class SPI wiring for JDK and Log4j2 support. Changes:
Technical Notes: Provider discovery is now more consistently exercised via SPI ( 🤖 Was this summary useful? React with 👍 or 👎 |
|
|
||
| @Override | ||
| public String getLoggerLevel(String loggerName) { | ||
| return this.loggerNameToLevelMap.get(loggerName); |
There was a problem hiding this comment.
Logging#getLoggerLevel() distinguishes "logger doesn't exist" (null) from "level inherited" (empty string), but Map#get() returns null for both missing keys and present-null values; this test double may mask bugs around those semantics.
Severity: low
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
|
|
||
| @Override | ||
| public String getParentLoggerName(String loggerName) { | ||
| return ""; |
There was a problem hiding this comment.
getParentLoggerName() currently always returns an empty string, but the Logging contract reserves empty string for the root logger and null for non-existent loggers; consider whether tests need more realistic parent behavior here.
Severity: low
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
This pull request introduces a new module for Java Logging (JDK), improves modularization, and refactors the codebase and tests to support the new structure. The most significant changes include adding the
microsphere-logging-jdkmodule, refactoring the existing JDK logging implementation and tests, and updating documentation and dependencies to reflect these changes.New JDK Logging Module and Refactoring:
microsphere-logging-jdk, dedicated to Java Logging (JDK) support, including its own POM, service provider configuration, and test suite. (microsphere-logging-jdk/pom.xml,microsphere-logging-jdk/src/main/resources/META-INF/services/io.microsphere.logging.Logging,microsphere-logging-jdk/src/main/java/io/microsphere/logging/jdk/JDKLogging.java,microsphere-logging-jdk/src/test/java/io/microsphere/logging/jdk/JDKLoggingTest.java) [1] [2] [3] [4]StandardLoggingclass toJDKLoggingand moved it from the core module to the new JDK module, updating its implementation and constants for clarity and modularity. (microsphere-logging-jdk/src/main/java/io/microsphere/logging/jdk/JDKLogging.java) [1] [2]Test and Service Configuration Updates:
TestingLogginginstead of the JDK logging implementation, and refactored related tests to use the new test logger for isolation and reliability. (microsphere-logging-core/src/test/resources/META-INF/services/io.microsphere.logging.Logging,microsphere-logging-core/src/test/java/io/microsphere/logging/TestingLogging.java,microsphere-logging-core/src/test/java/io/microsphere/logging/jmx/LoggingMXBeanAdapterTest.java,microsphere-logging-core/src/test/java/io/microsphere/logging/jmx/LoggingMXBeanRegistrarTest.java) [1] [2] [3] [4] [5] [6]StandardLoggingTestand replaced it with a new test class forJDKLogging. (microsphere-logging-core/src/test/java/io/microsphere/logging/jdk/StandardLoggingTest.java,microsphere-logging-jdk/src/test/java/io/microsphere/logging/jdk/JDKLoggingTest.java) [1] [2]Dependency and Documentation Updates:
microsphere-logging-dependencies/pom.xml,README.md) [1] [2]microsphere-logging-log4j2/src/main/java/io/microsphere/logging/log4j2/Log4j2Logger.java)README.md)These changes improve modularity, testability, and clarity in the codebase, making it easier to extend and maintain logging support for different backends.