Skip to content

Sync 'dev' branch#2

Merged
mercyblitz merged 25 commits intodev-1.xfrom
dev
Mar 15, 2026
Merged

Sync 'dev' branch#2
mercyblitz merged 25 commits intodev-1.xfrom
dev

Conversation

@mercyblitz
Copy link
Contributor

This pull request introduces the initial setup for the Microsphere Logging Framework. It establishes the core module, adds essential project documentation, and sets up CI/CD workflows for building and publishing with Maven. The most important changes are grouped below:

Project Structure and Core Implementation:

  • Added the microsphere-logging-core module with its pom.xml, defining dependencies on popular logging frameworks (SLF4J, Log4j, Logback, etc.) and test libraries.
  • Implemented core interfaces and utilities for logging, including Logging, LoggingLevelsResolver, DefaultLoggingLevelsResolver, and LoggingUtils. These provide a unified API for managing loggers and resolving supported log levels across frameworks. [1] [2] [3] [4]

Documentation and Community Standards:

  • Rewrote and expanded the README.md to provide an introduction, usage instructions, build steps, contribution guidelines, and documentation links.
  • Added a CODE_OF_CONDUCT.md to establish community standards and contributor expectations.

Build and CI/CD Automation:

  • Added Maven wrapper configuration for consistent build tooling.
  • Introduced GitHub Actions workflows:
    • maven-build.yml for automated builds, tests, and code coverage reporting on pushes and pull requests.
    • maven-publish.yml for publishing artifacts to Maven Central on release branch pushes or manual triggers.

Expand .gitignore to ignore common build artifacts, IDE project files (Eclipse/IntelliJ), temp/log/cache files, system files, Maven/Gradle outputs and compiler build dirs. Keeps .mvn/wrapper files explicitly and removes the obsolete replay_pid* entry. This reduces noise in VCS by excluding generated and environment-specific files.
Add CODE_OF_CONDUCT.md adapted from the Contributor Covenant v1.3.0. Defines expected community behavior and lists examples of unacceptable conduct, outlines maintainer responsibilities and enforcement, and provides a reporting contact (mercyblitz@gmail.com).
Replace minimal README with a comprehensive project README including badges, project introduction, module overview, getting-started instructions (BOM and dependency examples), build steps for Linux/Mac and Windows, contributing and issue reporting guidance, documentation links (DeepWiki, ZRead, GitHub Wiki), and license. Includes placeholders (TODO) for content and examples to be filled in later to improve onboarding and project visibility.
Introduce an initial Maven multi-module scaffold for the microsphere-logging project. Adds root pom.xml plus module poms: microsphere-logging-parent (central dependencyManagement and version properties for microsphere-java, slf4j, logback, junit), microsphere-logging-dependencies (dependencyManagement entry), microsphere-logging-core and microsphere-logging-test (module placeholders). The root POM defines project metadata, modules list, revision/java.version properties, SCM, distributionManagement and a snapshot repository.
Delete distributionManagement and repositories blocks referencing OSSRH (snapshot and staging) from the root pom.xml. Cleans up hardcoded Sonatype snapshot/staging configuration from the project POM.
Add Maven Wrapper files (mvnw, mvnw.cmd, .mvn/wrapper/maven-wrapper.properties) to pin Maven distribution (wrapperVersion 3.3.4) and use an Aliyun distribution URL. Add two GitHub Actions workflows: maven-build.yml (build/test matrix for Java 17/21/25 on dev and PRs, runs tests with test/coverage profiles and uploads Codecov) and maven-publish.yml (release branch publish with workflow_dispatch, deploys to OSSRH using secrets and publish/ci profiles). Also include a minor whitespace/newline cleanup in pom.xml.
Update Maven <revision> in pom.xml from 0.0.1-SNAPSHOT to 0.2.0-SNAPSHOT to reflect the new development version.
Introduce a logging core API and JDK-based implementation with JMX support and unit tests. Adds Logging interface, StandardLogging (JDK) implementation, LoggingMXBeanAdapter and PlatformLoggingMXBeanRegistrar to register Logging instances via the platform MBean server. Includes tests (StandardLoggingTest, LoggingMXBeanAdapterTest, PlatformLoggingMXBeanRegistrarTest) and a ThrowableLogging test provider plus a service loader resource. Update POMs: change packaging of core and test modules to jar and add optional/runtime/test dependencies (SLF4J, commons-logging, logback, junit, microsphere-java modules) and parent BOM dependency entries (JSR305, commons-logging, slf4j, logback). These changes provide a pluggable logging abstraction and automatic JMX registration for available implementations.
Introduce a register(ClassLoader) overload and make register() delegate to it using ClassLoaderUtils.getClassLoader. Replace direct ServiceLoader.load usage with ServiceLoaderUtils.loadServicesList and iterate as Iterable<Logging>, allowing explicit classloader control when discovering Logging implementations. Update imports accordingly and remove the unused ServiceLoader.load import.
Introduce LoggingMXBeanRegistrar (io.microsphere.logging.jmx) and remove the old PlatformLoggingMXBeanRegistrar. The new registrar loads Logging implementations via ServiceLoader, registers/adapts them to LoggingMXBean with improved handling for already-registered MBeans, exposes a JMX_DOMAIN constant (io.microsphere.logging) and provides getRegisteredLoggingObjectInstances(). Tests were renamed/updated to LoggingMXBeanRegistrarTest and adapted to the new API (constants, registerAll, getRegisteredLoggingObjectInstances) and utilities.
Align Codecov configuration and README badge: update the codecov action slug from microsphere-projects/microsphere-spring to microsphere-projects/microsphere-logging and change the README Codecov badge to point at the dev branch. This ensures coverage uploads and the badge reference target the correct repository and branch.
Introduce a LoggingLevelsResolver API and a DefaultLoggingLevelsResolver implementation (with unit tests) to derive supported logging level names from framework Level classes. Rename Logging.getSupportedLogLevels() to getSupportedLoggingLevels() and update implementations/tests (StandardLogging, ThrowableLogging, related tests) accordingly. Add a new microsphere-logging-logback module with a LogbackLogging stub and service descriptor for testing. Update POMs: add commons-logging, Log4j 1.x/2.x and Logback dependencies and version properties, register the new module, and include the logback/test artifacts in dependency management. These changes enable unified resolution of logging levels across multiple logging frameworks and add initial Logback support; note the API method rename is a breaking change that required test and implementation updates.
Change LoggingMXBeanRegistrar to an abstract class and add a private no-arg constructor to prevent instantiation, enforcing non-instantiable/utility-style usage for the registrar.
Integrate LogbackLogging with Logback API: use LoggerContext to list loggers, get/set levels, resolve supported levels, and determine parent logger names. Remove an optional microsphere-java-core dependency from the module POM. Add unit tests and a test Logback configuration (logback-test.xml) to validate behavior.
Add a new LoggerUtils utility class to encapsulate Logback interactions (getLoggerContext, getLogger, getLevel, getLevelString, setLoggerLevel). Refactor LogbackLogging to delegate level and logger lookups to LoggerUtils and remove its direct LoggerContext field and getLogger method. Update tests: remove the direct null-logger call in LogbackLoggingTest and add comprehensive LoggerUtilsTest to cover the new utility behavior. This centralizes Logback logic for reuse and improves testability.
Introduce LoggingUtils to centralize SPI-based Loading of Logging implementations (loadAll(ClassLoader)). Make Logging extend Prioritized so implementations can provide priority; add getPriority() implementation in StandardLogging returning MIN_PRIORITY. Update LoggingMXBeanRegistrar to use LoggingUtils.loadAll instead of ServiceLoader directly. Add unit test LoggingUtilsTest to validate SPI loading behavior. Small refactors: added necessary imports and a private constructor to LoggingUtils.
Update parent POM to support both JUnit 4 and JUnit Jupiter: set junit.version to 4.13.2, add junit-jupiter.version property, import the JUnit BOM using the Jupiter version, and add a managed junit (JUnit 4) entry. Add test module dependencies in microsphere-logging-test: include microsphere-logging-core, optional microsphere-java artifacts, JUnit 4 and JUnit Jupiter (including the engine), and test logging libraries (slf4j-api and logback-classic). These changes enable running tests with both JUnit 4 and JUnit 5 and provide required test/logging dependencies for the test module.
Add META-INF/services/io.microsphere.logging.Logging registering io.microsphere.logging.logback.LogbackLogging so the Logback implementation can be discovered via ServiceLoader.
Introduce a JUnit4 TestRule to run tests across different logging levels. Adds LoggingLevelsRule and LoggingLevelsStatement which iterate configured levels, set/reset the logger level for the test class, and invoke the test Statement for each level. Includes a basic LoggingLevelsRuleTest that demonstrates using the rule with TRACE/DEBUG/INFO. Also updates the module POM to add a test-scope dependency on microsphere-logging-logback.
Add a static import of org.junit.Assert.assertNotNull and call assertNotNull(loggingLevelsRule) in LoggingLevelsRuleTest.test() to verify the ClassRule is initialized.
Introduce a JUnit Jupiter @LoggingLevelsTest annotation and a LoggingLevelsTestExtension that provides class- and test-template invocation contexts to repeat tests across specified logging levels. The extension sets and resets logger levels for discovered Logging implementations and supplies parameters (level and index) to tests. Add example test classes (one commented method-level example and one active class-level test). Also fix JUnit4 LoggingLevelsStatement to use the test class package name for logger lookup (use package name instead of class name).
Add org.junit.vintage:junit-vintage-engine as a test dependency in microsphere-logging-test/pom.xml to enable JUnit Vintage support. Remove an outdated paragraph from the LoggingLevelsStatement Javadoc in microsphere-logging-test/src/main/java/io/microsphere/logging/test/junit4/LoggingLevelsStatement.java that described constructor signature requirements.
Add a suite of JUnit Jupiter utilities to run tests across different logging levels and manage logger state. New annotations LoggingLevelsTest and LoggingLevelsClass (class-level template) allow specifying target logging classes and levels. Implement a reusable generic LoggingLevelsExtension with concrete LoggingLevelsTestExtension and LoggingLevelsClassExtension, plus helper classes LoggingLevelCallback, LoggingLevelParameterResolver, LoggingLevelTemplateInvocationContext and a LoggingLevelsAttributes model. Update and add tests (LoggingLevelsClassTest, LoggingLevelsTestTest) and refactor previous inline logic into the new extension infrastructure to set/restore logger levels and inject level/index parameters into test methods.
Enhance LoggerUtilsTest by adding an assertion that getLogger(Class) returns a non-null logger instance (assertNotNull(getLogger(LoggerUtilsTest.class))). This verifies the class-based overload of getLogger; existing null and illegal-argument tests remain unchanged.
Replace utility-based parent lookup with direct string operations. The code now uses lastIndexOf/substring to compute the parent logger name and no longer checks for the parent Logger's existence (removing dependency on getLogger and substringBeforeLast). Behavior: if there's no dot in the name it returns the root logger name, otherwise returns the substring before the last dot. Unused imports were removed.
@mercyblitz mercyblitz merged commit 6e11c4a into dev-1.x Mar 15, 2026
6 checks passed
@augmentcode
Copy link

augmentcode bot commented Mar 15, 2026

🤖 Augment PR Summary

Summary: Bootstraps the Microsphere Logging Framework with an initial multi-module Maven structure and core logging/JMX abstractions.

Changes:

  • Added parent/BOM modules plus Maven wrapper to standardize builds.
  • Introduced microsphere-logging-core with the Logging management API, log-level resolution utilities, and JMX adapter/registrar.
  • Added a Logback integration module implementing Logging, including helper utilities and SPI registration.
  • Added microsphere-logging-test with JUnit4 and JUnit Jupiter helpers to iterate tests across logging levels.
  • Set up GitHub Actions workflows for CI build/coverage and release publishing.
  • Expanded documentation (README, Code of Conduct) and updated ignore rules.
Technical Notes: Discovery of Logging implementations is SPI-based (META-INF/services) and CI runs a Java version matrix.

🤖 Was this summary useful? React with 👍 or 👎

Copy link

@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. 9 suggestions posted.

Fix All in Augment

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

jobs:
build:
runs-on: ubuntu-latest
if: ${{ inputs.revision }}
Copy link

Choose a reason for hiding this comment

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

if: ${{ inputs.revision }} will evaluate as empty on push events (no inputs), so this job will be skipped even when pushing to the release branch. If you want publishing on push, consider conditioning on github.event_name or using an expression that defaults when inputs.revision is unset.

Severity: medium

Fix This in Augment

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

- name: Checkout Source
uses: actions/checkout@v5

- name: Setup JDK ${{ matrix.Java }}
Copy link

Choose a reason for hiding this comment

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

The step name uses ${{ matrix.Java }}, but the matrix key is java, so this will render blank/incorrect in the job UI. Using ${{ matrix.java }} here would match the configured matrix variable.

Severity: low

Fix This in Augment

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


@Override
public String getLoggerLevel(String loggerName) {
return getLevelString(loggerName);
Copy link

Choose a reason for hiding this comment

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

getLoggerLevel() returns the effective Logback level string even when the logger has no explicit level, but Logging#getLoggerLevel’s contract says inherited levels should return an empty string. This mismatch can break callers that rely on the LoggingMXBean-compatible semantics.

Severity: medium

Fix This in Augment

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


@Override
public void setLoggerLevel(String loggerName, String levelName) {
LoggerUtils.setLoggerLevel(loggerName, levelName);
Copy link

Choose a reason for hiding this comment

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

setLoggerLevel(loggerName, null) is documented on Logging as “inherit from parent”, but LoggerUtils.setLoggerLevel currently maps null to Level.DEBUG via Level.toLevel(null). This makes the Logback implementation violate the interface contract and prevents callers from clearing an explicitly-set level.

Severity: high

Fix This in Augment

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

@Override
public String getParentLoggerName(String loggerName) {
if (ROOT_LOGGER_NAME.equals(loggerName)) {
return null;
Copy link

Choose a reason for hiding this comment

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

For the root logger, getParentLoggerName returns null, but Logging#getParentLoggerName documents returning an empty string for the root logger (and null for non-existent loggers). Returning null here makes root indistinguishable from “logger does not exist” for callers expecting LoggingMXBean semantics.

Severity: medium

Fix This in Augment

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


@Override
public boolean equals(Object obj) {
return this.logging.equals(obj);
Copy link

Choose a reason for hiding this comment

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

equals() delegates directly to logging.equals(obj), which can violate the equals contract (e.g., adapter.equals(logging) may be true while logging.equals(adapter) is false). This can cause surprising behavior in collections and when comparing adapters vs delegates.

Severity: medium

Fix This in Augment

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

}

private static ObjectName createObjectName(String type) throws MalformedObjectNameException {
return getInstance(JMX_DOMAIN + ":type=" + type);
Copy link

Choose a reason for hiding this comment

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

ObjectName is built via string concatenation using logging.getName() as the type value; if a Logging implementation returns characters like ,, =, : or *, createObjectName will throw MalformedObjectNameException. Consider quoting/escaping the type value (e.g., ObjectName.quote(...)) to make this robust for arbitrary Logging#getName() values.

Severity: medium

Fix This in Augment

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

for (int i = 0; i < length; i++) {
String loggerName = loggerNames[i];
String originalLevel = originalLevels[i];
logging.setLoggerLevel(loggerName, originalLevel);
Copy link

Choose a reason for hiding this comment

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

The stored originalLevel may be "" (inherited) per Logging#getLoggerLevel, but resetting via setLoggerLevel(loggerName, originalLevel) will pass the empty string instead of null and can throw IllegalArgumentException (or fail to restore inherited behavior). Consider normalizing "" back to null when recovering the original level.

Severity: medium

Other Locations
  • microsphere-logging-test/src/main/java/io/microsphere/logging/test/junit4/LoggingLevelsStatement.java:72

Fix This in Augment

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

*/
public class DefaultLoggingLevelsResolver implements LoggingLevelsResolver {

public static DefaultLoggingLevelsResolver INSTANCE = new DefaultLoggingLevelsResolver();
Copy link

Choose a reason for hiding this comment

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

INSTANCE is mutable (public static but not final), so it can be reassigned at runtime and lead to surprising behavior for callers expecting a singleton constant. Making it public static final would prevent accidental replacement.

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