Skip to content

Commit

Permalink
yegor256#28 added slf4j wrappers for Takes,Back ,Front ,Take,Pass
Browse files Browse the repository at this point in the history
fixed PMD violations
  • Loading branch information
dmzaytsev committed Mar 28, 2015
1 parent 301b7bd commit 54ae505
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
30 changes: 27 additions & 3 deletions src/main/java/org/takes/facets/slf4j/LogWrap.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,33 @@
* @version $Id$
* @since 0.11
*/
@SuppressWarnings({ "PMD.CyclomaticComplexity", "PMD.LoggerIsNotStaticFinal" })
public class LogWrap {
/**
* Log levels.
*/
public static enum Level { TRACE, DEBUG, INFO, WARN, SEVERE };
public enum Level {
/**
* Trace level.
*/
TRACE,
/**
* Debug level.
*/
DEBUG,
/**
* Info level.
*/
INFO,
/**
* Warn level.
*/
WARN,
/**
* Severe level.
*/
SEVERE
};

/**
* Log level.
Expand All @@ -49,7 +71,8 @@ public static enum Level { TRACE, DEBUG, INFO, WARN, SEVERE };
/**
* Logger.
*/
private Logger logger;
private final transient Logger logger;

/**
* Ctor.
* @param clazz Logger class
Expand All @@ -68,7 +91,8 @@ public LogWrap(final Class<?> clazz, final LogWrap.Level lvl) {
// @checkstyle JavadocLocationCheck (1 line)
// @checkstyle CyclomaticComplexityCheck (1 line)
public final void log(final String format, final Object... param) {
if (this.level == LogWrap.Level.TRACE && this.logger.isTraceEnabled()) {
if (this.level == LogWrap.Level.TRACE
&& this.logger.isTraceEnabled()) {
this.logger.trace(String.format(format, param));
} else if (
this.level == LogWrap.Level.DEBUG
Expand Down
1 change: 1 addition & 0 deletions src/test/java/org/takes/facets/slf4j/BkLoggedTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public void logsMessage() throws IOException {
new BkLogged(
new Back() {
@Override
@SuppressWarnings("PMD.UncommentedEmptyMethod")
public void accept(final Socket socket) throws IOException {
}
}, LogWrap.Level.WARN
Expand Down
1 change: 1 addition & 0 deletions src/test/java/org/takes/facets/slf4j/FtLoggedTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public void logsMessage() throws IOException {
new FtLogged(
new Front() {
@Override
@SuppressWarnings("PMD.UncommentedEmptyMethod")
public void start(final Exit exit) throws IOException {
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/takes/facets/slf4j/PsLoggedTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void logsMessage() throws IOException {
final Appender appender = Mockito.mock(Appender.class);
Mockito.when(appender.getName()).thenReturn("MOCK");
Logger.getRootLogger().addAppender(appender);
Pass pass = new PsLogged(
final Pass pass = new PsLogged(
new Pass() {
@Override
public Iterator<Identity> enter(
Expand Down

0 comments on commit 54ae505

Please sign in to comment.