Skip to content

Dev#6

Merged
mercyblitz merged 7 commits into
mainfrom
dev
Mar 16, 2026
Merged

Dev#6
mercyblitz merged 7 commits into
mainfrom
dev

Conversation

@mercyblitz
Copy link
Copy Markdown
Contributor

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-jdk module, refactoring the existing JDK logging implementation and tests, and updating documentation and dependencies to reflect these changes.

New JDK Logging Module and Refactoring:

  • Added a new Maven module, 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]
  • Refactored the old StandardLogging class to JDKLogging and 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:

  • Updated test service loader configuration to use TestingLogging instead 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]
  • Removed the old StandardLoggingTest and replaced it with a new test class for JDKLogging. (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:

  • Updated the dependencies module and documentation to include the new JDK logging module and log4j2, and clarified module descriptions in the README. (microsphere-logging-dependencies/pom.xml, README.md) [1] [2]
  • Added a new logger adapter for log4j2 to support modular logging backends. (microsphere-logging-log4j2/src/main/java/io/microsphere/logging/log4j2/Log4j2Logger.java)
  • Cleaned up and removed unused example sections from the README. (README.md)

These changes improve modularity, testability, and clarity in the codebase, making it easier to extend and maintain logging support for different backends.

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.
@mercyblitz mercyblitz merged commit 4fb0aaa into main Mar 16, 2026
7 checks passed
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ Complexity Δ
...in/java/io/microsphere/logging/jdk/JDKLogging.java 100.00% <100.00%> (ø) 9.00 <3.00> (?)
...va/io/microsphere/logging/log4j2/Log4j2Logger.java 100.00% <100.00%> (ø) 17.00 <17.00> (?)
...icrosphere/logging/log4j2/Log4j2LoggerFactory.java 100.00% <100.00%> (ø) 4.00 <4.00> (?)
...a/io/microsphere/logging/log4j2/Log4j2Logging.java 100.00% <100.00%> (ø) 11.00 <3.00> (+2.00)
...io/microsphere/logging/logback/LogbackLogging.java 100.00% <100.00%> (ø) 11.00 <3.00> (+2.00)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@augmentcode
Copy link
Copy Markdown

augmentcode Bot commented Mar 16, 2026

🤖 Augment PR Summary

Summary: This PR modularizes backend implementations and adds first-class SPI wiring for JDK and Log4j2 support.

Changes:

  • Introduced a new Maven module microsphere-logging-jdk and moved/renamed StandardLogging to JDKLogging, including an SPI provider entry and new tests.
  • Refactored test SPI configuration in microsphere-logging-core to use a dedicated TestingLogging implementation for isolation (and updated JMX-related tests accordingly).
  • Added a Log4j2 Logger adapter (Log4j2Logger) plus an SPI-discoverable LoggerFactory (Log4j2LoggerFactory) and corresponding tests.
  • Standardized/cached supported level sets via ALL_LEVELS constants and added explicit PRIORITY/getPriority() for Logback and Log4j2 logging implementations.
  • Updated the root aggregator POM to include the new JDK module and updated the BOM (microsphere-logging-dependencies) to manage its version.
  • Updated README.md module listing to document the new JDK and Log4j2 modules and removed an unused example section.

Technical Notes: Provider discovery is now more consistently exercised via SPI (ServiceLoader) in tests, and implementation selection is influenced by explicit priorities across backends.

🤖 Was this summary useful? React with 👍 or 👎

Copy link
Copy Markdown

@augmentcode augmentcode Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 2 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.


@Override
public String getLoggerLevel(String loggerName) {
return this.loggerNameToLevelMap.get(loggerName);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.


@Override
public String getParentLoggerName(String loggerName) {
return "";
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant