Skip to content

Dev#7

Merged
mercyblitz merged 7 commits into
dev-1.xfrom
dev
Mar 16, 2026
Merged

Dev#7
mercyblitz merged 7 commits into
dev-1.xfrom
dev

Conversation

@mercyblitz
Copy link
Copy Markdown
Contributor

This pull request introduces a new microsphere-logging-jdk module for JDK logging support, updates the project structure and documentation, and improves test coverage and modularity. It also replaces direct usage of the JDK logging implementation in tests with a new TestingLogging mock class, and updates service loader configurations accordingly.

New JDK Logging Module:

  • Added the microsphere-logging-jdk module, including its own pom.xml, service loader configuration, and implementation class JDKLogging, which replaces the previous StandardLogging class. The new module provides JDK logging integration in a more modular fashion. (microsphere-logging-jdk/pom.xml [1] microsphere-logging-jdk/src/main/java/io/microsphere/logging/jdk/JDKLogging.java [2] microsphere-logging-jdk/src/main/resources/META-INF/services/io.microsphere.logging.Logging [3]
  • Added a comprehensive test class for JDKLogging to ensure its correctness. (microsphere-logging-jdk/src/test/java/io/microsphere/logging/jdk/JDKLoggingTest.java microsphere-logging-jdk/src/test/java/io/microsphere/logging/jdk/JDKLoggingTest.javaR1-R112)

Project Structure and Dependency Updates:

  • Updated the project documentation (README.md) to list the new microsphere-logging-jdk and microsphere-logging-log4j2 modules and removed the empty "Quick Examples" section. [1] [2]
  • Added microsphere-logging-jdk as a dependency in the microsphere-logging-dependencies module. (microsphere-logging-dependencies/pom.xml microsphere-logging-dependencies/pom.xmlR30-R35)

Testing Improvements and Refactoring:

  • Introduced a new TestingLogging class to be used as a mock implementation in tests, replacing direct usage of the JDK logging implementation. Updated relevant tests and service loader configuration to use this class. (microsphere-logging-core/src/test/java/io/microsphere/logging/TestingLogging.java [1] microsphere-logging-core/src/test/resources/META-INF/services/io.microsphere.logging.Logging [2] microsphere-logging-core/src/test/java/io/microsphere/logging/jmx/LoggingMXBeanAdapterTest.java [3] [4] [5] microsphere-logging-core/src/test/java/io/microsphere/logging/jmx/LoggingMXBeanRegistrarTest.java [6]

Log4j2 Integration:

Class and File Renaming:

  • Renamed StandardLogging to JDKLogging and moved it from the core module to the new JDK module, updating constants, priorities, and documentation for clarity and consistency. (microsphere-logging-jdk/src/main/java/io/microsphere/logging/jdk/JDKLogging.java [1] [2]

These changes modularize JDK logging support, improve testability, and extend the framework's extensibility for other logging systems.

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 0fe0e14 into dev-1.x Mar 16, 2026
12 checks passed
@augmentcode
Copy link
Copy Markdown

augmentcode Bot commented Mar 16, 2026

🤖 Augment PR Summary

Summary: This PR modularizes JDK logging support and expands logging framework integrations while improving test isolation.

Changes:

  • Introduced a new microsphere-logging-jdk module and moved the former JDK implementation to JDKLogging with SPI registration.
  • Updated the reactor build (pom.xml) and BOM (microsphere-logging-dependencies) to include the new JDK module.
  • Refreshed README.md to document the added modules (jdk, log4j2).
  • Added TestingLogging to decouple core/JMX tests from the real JDK logging MXBean and updated test SPI configuration accordingly.
  • Enhanced Logback/Log4j2 implementations with explicit PRIORITY and cached ALL_LEVELS constants.
  • Added Log4j2 logger adapter + LoggerFactory SPI (Log4j2Logger, Log4j2LoggerFactory) and new unit tests for JDK/Log4j2 behavior.

Technical Notes: ServiceLoader-based discovery is now used in more tests to validate SPI wiring, and JMX registration tests are isolated via a dedicated testing implementation.

🤖 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 getParentLoggerName(String 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.

TestingLogging#getParentLoggerName() always returns an empty string, which doesn’t match the Logging contract for non-root/non-existent loggers and can hide hierarchy-related bugs in tests that rely on parent resolution.

Severity: low

Fix This in Augment

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

*/
public class Log4j2LoggerFactory extends LoggerFactory {

public static final String LOG4J2_LOGGER_CLASS_NAME = "org.apache.logging.log4j.Logger";
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

If LoggerFactory uses getDelegateLoggerClassName() as an availability check, using org.apache.logging.log4j.Logger can succeed with only log4j-api present, but Log4j2Logger/LoggerUtils depend on log4j-core and would then fail at runtime.

Severity: medium

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