diff --git a/pom.xml b/pom.xml index 9133e1f..ade260a 100644 --- a/pom.xml +++ b/pom.xml @@ -31,7 +31,7 @@ io.github.elf4j elf4j-engine - 13.0.9 + 13.0.10 jar elf4j-engine A stand-alone Java log engine implementing the ELF4J (Easy Logging Facade for Java) API @@ -219,6 +219,15 @@ com.diffplug.spotless spotless-maven-plugin 2.40.0 + + + spotless-apply-id + process-sources + + apply + + + diff --git a/src/main/java/elf4j/engine/NativeLogger.java b/src/main/java/elf4j/engine/NativeLogger.java index 6fbb075..1a871c2 100644 --- a/src/main/java/elf4j/engine/NativeLogger.java +++ b/src/main/java/elf4j/engine/NativeLogger.java @@ -40,20 +40,20 @@ @ThreadSafe public class NativeLogger implements Logger { /** - * Name of this logger's "owner class" - the logging service client class that first requested this logger instance - * via the {@link Logger#instance()} service access method. The owner class is usually the same as the "caller - * class" - the client class that calls the service interface methods such as {@link Logger#log(Object)}. + * Name of this logger's declaring class - the logging service client class that first requested this logger + * instance via the {@link Logger#instance()} service access method. The declaring class is usually the same as the + * "caller class" - the client class that calls the service interface methods such as {@link Logger#log(Object)}. *

- * In rare and not-recommended scenarios, the owner class can be different from the caller class: e.g. the owner - * class could pass a reference of this logger instance out to a different/caller class. Once set, though, the value - * of this field will never change even when the owner class is different from the caller class. + * In rare and not-recommended scenarios, the declaring class can be different from the caller class: e.g. the + * declaring class could pass a reference of this logger instance out to a different/caller class. Once set, though, + * the value of this field will never change even when the declaring class is different from the caller class. *

* To reduce the frequency of having to walk the call stack in order to locate the caller class, this native ELF4J - * implementation assumes the owner and caller class to be one and the same. Thus, for logging output that requires - * only the caller class name, this field will be used in liu of checking the stack trace; i.e. the stack trace - * walking is needed only when more caller details (e.g. method name, file name, line number) are required. + * implementation assumes the declaring and caller class to be one and the same. Thus, for logging output that + * requires only the caller class name, this field will be used in liu of checking the stack trace; i.e. the stack + * trace walking is needed only when more caller details (e.g. method name, file name, line number) are required. */ - private final @NonNull String ownerClassName; + private final @NonNull String declaringClassName; private final @NonNull Level level; private final @NonNull NativeLoggerFactory nativeLoggerFactory; @@ -61,21 +61,23 @@ public class NativeLogger implements Logger { /** * Constructor only meant to be used by {@link NativeLoggerFactory} and this class itself * - * @param ownerClassName name of the owner class that requested this instance via the {@link Logger#instance()} - * method - * @param level severity level of this logger instance + * @param declaringClassName name of the declaring class that requested this instance via the + * {@link Logger#instance()} method + * @param level severity level of this logger instance * @param nativeLoggerFactory log service access point from this instance, not reloadable */ public NativeLogger( - @NonNull String ownerClassName, @NonNull Level level, @NonNull NativeLoggerFactory nativeLoggerFactory) { - this.ownerClassName = ownerClassName; + @NonNull String declaringClassName, + @NonNull Level level, + @NonNull NativeLoggerFactory nativeLoggerFactory) { + this.declaringClassName = declaringClassName; this.level = level; this.nativeLoggerFactory = nativeLoggerFactory; } @Override public NativeLogger atLevel(Level level) { - return this.level == level ? this : this.nativeLoggerFactory.getLogger(level, this.ownerClassName); + return this.level == level ? this : this.nativeLoggerFactory.getLogger(level, this.declaringClassName); } @Override @@ -121,10 +123,10 @@ public LogService getLogService() { } /** - * @return owner/caller class of this logger instance + * @return declaring/caller class of this logger instance */ - public @NonNull String getOwnerClassName() { - return this.ownerClassName; + public @NonNull String getDeclaringClassName() { + return this.declaringClassName; } private void service(Throwable throwable, Object message, Object[] arguments) { diff --git a/src/main/java/elf4j/engine/service/LogEvent.java b/src/main/java/elf4j/engine/service/LogEvent.java index f981550..5906fa6 100644 --- a/src/main/java/elf4j/engine/service/LogEvent.java +++ b/src/main/java/elf4j/engine/service/LogEvent.java @@ -98,7 +98,7 @@ public class LogEvent { * @return the name of the application client class calling the logging method of this logger instance */ public String getCallerClassName() { - return callerFrame != null ? callerFrame.getClassName() : nativeLogger.getOwnerClassName(); + return callerFrame != null ? callerFrame.getClassName() : nativeLogger.getDeclaringClassName(); } /** diff --git a/src/main/java/elf4j/engine/service/configuration/OverridingCallerLevels.java b/src/main/java/elf4j/engine/service/configuration/OverridingCallerLevels.java index 461de8d..caaf33b 100644 --- a/src/main/java/elf4j/engine/service/configuration/OverridingCallerLevels.java +++ b/src/main/java/elf4j/engine/service/configuration/OverridingCallerLevels.java @@ -83,7 +83,7 @@ private static Optional getAsLevel(String levelKey, @NonNull Properties p */ public Level getMinimumOutputLevel(@NonNull NativeLogger nativeLogger) { return this.sortedCallerClassNameSpaces.stream() - .filter(classNameSpace -> nativeLogger.getOwnerClassName().startsWith(classNameSpace)) + .filter(classNameSpace -> nativeLogger.getDeclaringClassName().startsWith(classNameSpace)) .findFirst() .map(this.configuredLevels::get) .orElse(nativeLogger.getLevel()); diff --git a/src/test/java/elf4j/engine/IntegrationTest.java b/src/test/java/elf4j/engine/IntegrationTest.java index 5cb9ad4..ffc9314 100644 --- a/src/test/java/elf4j/engine/IntegrationTest.java +++ b/src/test/java/elf4j/engine/IntegrationTest.java @@ -46,7 +46,7 @@ void hey() { new Exception("Test ex message"), this.getClass()); - assertEquals(this.getClass().getName(), ((NativeLogger) logger).getOwnerClassName()); + assertEquals(this.getClass().getName(), ((NativeLogger) logger).getDeclaringClassName()); } } } diff --git a/src/test/java/elf4j/engine/NativeLoggerFactoryTest.java b/src/test/java/elf4j/engine/NativeLoggerFactoryTest.java index 4ace9b3..0f1a8c8 100644 --- a/src/test/java/elf4j/engine/NativeLoggerFactoryTest.java +++ b/src/test/java/elf4j/engine/NativeLoggerFactoryTest.java @@ -66,7 +66,7 @@ void level() { @Test void name() { - assertSame(this.getClass().getName(), sut.logger().getOwnerClassName()); + assertSame(this.getClass().getName(), sut.logger().getDeclaringClassName()); } @Test diff --git a/src/test/java/elf4j/engine/NativeLoggerTest.java b/src/test/java/elf4j/engine/NativeLoggerTest.java index c5433f3..dd49b93 100644 --- a/src/test/java/elf4j/engine/NativeLoggerTest.java +++ b/src/test/java/elf4j/engine/NativeLoggerTest.java @@ -56,7 +56,7 @@ void instanceForDifferentLevel() { NativeLogger warn = (NativeLogger) info.atWarn(); assertNotSame(warn, info); - assertEquals(info.getOwnerClassName(), warn.getOwnerClassName()); + assertEquals(info.getDeclaringClassName(), warn.getDeclaringClassName()); assertEquals(WARN, warn.getLevel()); }