Skip to content

Commit

Permalink
fix SLF4J SLF4J-560
Browse files Browse the repository at this point in the history
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
  • Loading branch information
ceki committed Sep 14, 2022
1 parent bae56f5 commit 593f89f
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions slf4j-api/src/main/java/org/slf4j/Logger.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,30 +96,37 @@ public interface Logger {
public String getName();

/**
* Make a new {@link LoggingEventBuilder} instance as appropriate for this logger and the
* desired {@link Level} passed as parameter. If this Logger is disabled for the given Level, then
* a {@link NOPLoggingEventBuilder} is returned.
*
*
* <p>Make a new {@link LoggingEventBuilder} instance as appropriate for this logger implementation.
* The default implementation returns an instance of {@link DefaultLoggingEventBuilder}.</p>
*
* <p>Note that the {@link LoggingEventBuilder} should be built for all levels, independently of the level.
* In other words, this method is an <b>unconditional</b> constructor for the {@link LoggingEventBuilder}
* appropriate for this logger implementation.</p>
*
* @param level desired level for the event builder
* @return a new {@link LoggingEventBuilder} instance as appropriate for this logger
* @since 2.0
*/
default public LoggingEventBuilder makeLoggingEventBuilder(Level level) {
if (isEnabledForLevel(level)) {
return new DefaultLoggingEventBuilder(this, level);
} else {
return NOPLoggingEventBuilder.singleton();
}
return new DefaultLoggingEventBuilder(this, level);
}

/**
* A convenient alias for {@link #makeLoggingEventBuilder}.
*
* Make a new {@link LoggingEventBuilder} instance as appropriate for this logger and the
* desired {@link Level} passed as parameter. If this Logger is disabled for the given Level, then
* a {@link NOPLoggingEventBuilder} is returned.
*
*
* @param level desired level for the event builder
* @return a new {@link LoggingEventBuilder} instance as appropriate for this logger
* @since 2.0
*/
default public LoggingEventBuilder atLevel(Level level) {
return makeLoggingEventBuilder(level);
if (isEnabledForLevel(level)) {
return makeLoggingEventBuilder(level);
} else {
return NOPLoggingEventBuilder.singleton();
}
}


Expand Down

0 comments on commit 593f89f

Please sign in to comment.