Skip to content

Sync 'dev' branch#13

Merged
mercyblitz merged 4 commits into
mainfrom
dev
Mar 17, 2026
Merged

Sync 'dev' branch#13
mercyblitz merged 4 commits into
mainfrom
dev

Conversation

@mercyblitz
Copy link
Copy Markdown
Contributor

This pull request introduces a new getRootLoggerName() method to the Logging interface and its implementations, standardizes the handling of root logger names across logging frameworks, and moves the default logic for determining a parent logger name into the interface itself. It also refactors and cleans up related code and tests, and renames the Log4j logger class for clarity.

API and Interface Changes

  • Added a new getRootLoggerName() method to the Logging interface, with implementations provided for Java Util Logging, Log4j, Log4j2, and Logback. This method returns the name of the root logger for each framework. ([[1]](https://github.com/microsphere-projects/microsphere-logging/pull/13/files#diff-ab0af1d580b76d9d2ec03297ffbd99f5c641f40c822a77fb561b2165b2af3f0aR41-R48), [[2]](https://github.com/microsphere-projects/microsphere-logging/pull/13/files#diff-820f87886e6263649e34cfd61a02fdd044a7785d69d26409f016834b356d4858R39-R43), [[3]](https://github.com/microsphere-projects/microsphere-logging/pull/13/files#diff-904199cabf9b2ce4a054a31a6d7b9177a85a97642acdd2be224d2a6db284e2f1R59-R63), [[4]](https://github.com/microsphere-projects/microsphere-logging/pull/13/files#diff-96dbc8b1d7ea6a605251799aa481feedeaba3ee62f20f6a183fd5e72f34356c8R55-R59), [[5]](https://github.com/microsphere-projects/microsphere-logging/pull/13/files#diff-ccade0afe08029cad82834690a561b28ba804ce7c0dafc81b3064eaaba323701R55-R59))
  • Moved the default logic for getParentLoggerName() into the Logging interface. Implementations now inherit this logic, reducing code duplication. ([[1]](https://github.com/microsphere-projects/microsphere-logging/pull/13/files#diff-ab0af1d580b76d9d2ec03297ffbd99f5c641f40c822a77fb561b2165b2af3f0aL107-R128), [[2]](https://github.com/microsphere-projects/microsphere-logging/pull/13/files#diff-904199cabf9b2ce4a054a31a6d7b9177a85a97642acdd2be224d2a6db284e2f1L85-L97), [[3]](https://github.com/microsphere-projects/microsphere-logging/pull/13/files#diff-96dbc8b1d7ea6a605251799aa481feedeaba3ee62f20f6a183fd5e72f34356c8L79-L91), [[4]](https://github.com/microsphere-projects/microsphere-logging/pull/13/files#diff-ccade0afe08029cad82834690a561b28ba804ce7c0dafc81b3064eaaba323701L79-L91))

Log4j Module Refactoring

  • Renamed the Log4j logger class from Log4j2Logger to Log4jLogger for clarity, updated all usages, and adjusted related test classes and documentation. ([[1]](https://github.com/microsphere-projects/microsphere-logging/pull/13/files#diff-e9fd7d5fe56e264a506148b2acd0808287c0430d095c5f402ebda1b97c6557d5L36-R40), [[2]](https://github.com/microsphere-projects/microsphere-logging/pull/13/files#diff-5c4d858300434dacb607e055a9d512d1aea8dc35a40f41cccfcc77448ccaa960L43-R43), [[3]](https://github.com/microsphere-projects/microsphere-logging/pull/13/files#diff-86923048db8ddb54676686dde1ed6a8e2943be536ef509173ed135ff308bda50L54-R54), [[4]](https://github.com/microsphere-projects/microsphere-logging/pull/13/files#diff-911434e95cfb295581e764104a13c5b9673676a162ce0a912563082c244da7b0L33-R47))
  • Improved documentation and added a constant for the root logger name in Log4j's LoggerUtils. ([[1]](https://github.com/microsphere-projects/microsphere-logging/pull/13/files#diff-d82736e2f57822c9a055a8312ed885004298e7440c98cf554bf95b93e289782aL32-R32), [[2]](https://github.com/microsphere-projects/microsphere-logging/pull/13/files#diff-d82736e2f57822c9a055a8312ed885004298e7440c98cf554bf95b93e289782aR42-R44))

Testing Improvements

  • Added and updated unit tests for the new getRootLoggerName() method in all logging modules to ensure correct behavior. ([[1]](https://github.com/microsphere-projects/microsphere-logging/pull/13/files#diff-ef8e18132b898d65cf9fd504eb439a697f96307e91f959e83d560bac6f749208L49-R116), [[2]](https://github.com/microsphere-projects/microsphere-logging/pull/13/files#diff-3d2a9c1e99f64926b64a67a9f45e923474d86f3eee32ea76623643c1f8e8efe5R62-R71), [[3]](https://github.com/microsphere-projects/microsphere-logging/pull/13/files#diff-0b4ee10b418b329de4ecb190981a84293c95c0c7cb5b9dd6f9276fd001a4b65cR66-R70), [[4]](https://github.com/microsphere-projects/microsphere-logging/pull/13/files#diff-0c42b56500cd52008c55385517b2ba6058f8bd94dcb899b36afcddcef139de0eR68-R72))

Documentation

  • Added a missing Javadoc link for the new Log4j module in the README.md. ([README.mdR221](https://github.com/microsphere-projects/microsphere-logging/pull/13/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5R221))

Rename the Log4j logger implementation from Log4j2Logger to Log4jLogger (class and constructor) across the microsphere-log4j module. Update Log4jLoggerFactory to return the renamed class and adjust unit tests and Javadoc references accordingly. Also add microsphere-log4j link to the README.
Introduce getRootLoggerName() to the Logging API and implement it in concrete logging adapters. Add ROOT_LOGGER_NAME constants (Java logging and Log4j util) and update tests to assert root name. Move parent resolution into a default getParentLoggerName() in Logging (using DOT) and remove duplicated parent-lookup implementations from Log4j, Log4j2 and Logback. Update TestingLogging and ThrowableLogging test helpers to return a root name, and adjust tests (variable rename and assertions) accordingly.
Add a new LoggingTest unit test to verify Logging behavior (root name, logger names, supported levels, get/set level, parent names, name and priority). Update TestingLogging to use a linked (ordered) map by replacing HashMap with MapUtils.newLinkedHashMap and adding the corresponding static import, ensuring logger insertion order is preserved and removing the unused HashMap import.
Import assertNull and add an assertion verifying that Logging.getParentLoggerName("") returns null. This ensures the logging implementation correctly handles an empty logger name case in tests.
@mercyblitz mercyblitz merged commit e313a14 into main Mar 17, 2026
6 checks passed
@augmentcode
Copy link
Copy Markdown

augmentcode Bot commented Mar 17, 2026

🤖 Augment PR Summary

Summary: This PR standardizes root logger handling across supported logging frameworks and reduces duplicated parent-logger resolution logic.

Changes:

  • Added Logging#getRootLoggerName() and implemented it for Java Util Logging, Log4j, Log4j2, and Logback.
  • Moved the dot-delimited parent-name calculation into a default Logging#getParentLoggerName() implementation and removed duplicated framework-specific implementations.
  • Log4j module: renamed the Log4j logger adapter from Log4j2Logger to Log4jLogger and updated the factory/tests accordingly.
  • Introduced/updated unit tests to cover getRootLoggerName() and the interface-level default behavior.
  • Documentation: added the missing Javadoc link for microsphere-log4j in the README.

Technical Notes: Root logger names differ by framework (e.g., JUL/Log4j2 use "", Logback uses "ROOT", Log4j uses "root"), and the new API makes this explicit via getRootLoggerName().

🤖 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.

if (Objects.equals(getRootLoggerName(), loggerName)) {
return null;
}
int lastDotIndex = loggerName.lastIndexOf(DOT);
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(String loggerName) will throw an NPE when loggerName is null (because of loggerName.lastIndexOf(...)), even though the Javadoc suggests returning null when the logger doesn’t exist.

Severity: medium

Fix This in Augment

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

@Nullable
String getParentLoggerName(String loggerName);
default String getParentLoggerName(String loggerName) {
if (Objects.equals(getRootLoggerName(), 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.

The Javadoc for getParentLoggerName still describes returning an empty string for the root logger, but the default implementation returns null when loggerName equals getRootLoggerName() (and may return a non-empty root name for top-level loggers like Logback).

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