Skip to content

Commit 593f89f

Browse files
committed
fix SLF4J SLF4J-560
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
1 parent bae56f5 commit 593f89f

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

slf4j-api/src/main/java/org/slf4j/Logger.java

+20-13
Original file line numberDiff line numberDiff line change
@@ -96,30 +96,37 @@ public interface Logger {
9696
public String getName();
9797

9898
/**
99-
* Make a new {@link LoggingEventBuilder} instance as appropriate for this logger and the
100-
* desired {@link Level} passed as parameter. If this Logger is disabled for the given Level, then
101-
* a {@link NOPLoggingEventBuilder} is returned.
102-
*
103-
*
99+
* <p>Make a new {@link LoggingEventBuilder} instance as appropriate for this logger implementation.
100+
* The default implementation returns an instance of {@link DefaultLoggingEventBuilder}.</p>
101+
*
102+
* <p>Note that the {@link LoggingEventBuilder} should be built for all levels, independently of the level.
103+
* In other words, this method is an <b>unconditional</b> constructor for the {@link LoggingEventBuilder}
104+
* appropriate for this logger implementation.</p>
105+
*
104106
* @param level desired level for the event builder
105107
* @return a new {@link LoggingEventBuilder} instance as appropriate for this logger
106108
* @since 2.0
107109
*/
108110
default public LoggingEventBuilder makeLoggingEventBuilder(Level level) {
109-
if (isEnabledForLevel(level)) {
110-
return new DefaultLoggingEventBuilder(this, level);
111-
} else {
112-
return NOPLoggingEventBuilder.singleton();
113-
}
111+
return new DefaultLoggingEventBuilder(this, level);
114112
}
115113

116114
/**
117-
* A convenient alias for {@link #makeLoggingEventBuilder}.
118-
*
115+
* Make a new {@link LoggingEventBuilder} instance as appropriate for this logger and the
116+
* desired {@link Level} passed as parameter. If this Logger is disabled for the given Level, then
117+
* a {@link NOPLoggingEventBuilder} is returned.
118+
*
119+
*
120+
* @param level desired level for the event builder
121+
* @return a new {@link LoggingEventBuilder} instance as appropriate for this logger
119122
* @since 2.0
120123
*/
121124
default public LoggingEventBuilder atLevel(Level level) {
122-
return makeLoggingEventBuilder(level);
125+
if (isEnabledForLevel(level)) {
126+
return makeLoggingEventBuilder(level);
127+
} else {
128+
return NOPLoggingEventBuilder.singleton();
129+
}
123130
}
124131

125132

0 commit comments

Comments
 (0)