diff --git a/core/src/main/java/org/nzbhydra/indexers/Indexer.java b/core/src/main/java/org/nzbhydra/indexers/Indexer.java index 39c01343f..66de8754d 100644 --- a/core/src/main/java/org/nzbhydra/indexers/Indexer.java +++ b/core/src/main/java/org/nzbhydra/indexers/Indexer.java @@ -61,7 +61,7 @@ import java.util.regex.Pattern; import java.util.stream.Collectors; -@SuppressWarnings("TypeParameterHidesVisibleType") +@SuppressWarnings({"TypeParameterHidesVisibleType", "StringConcatenationArgumentToLogCall"}) @Reflective @Component public abstract class Indexer { @@ -479,7 +479,6 @@ public Optional tryParseDate(String dateString) { } - @Override public boolean equals(Object o) { if (this == o) { @@ -503,27 +502,27 @@ public String toString() { } protected void warn(String msg) { - getLogger().warn("{}: {}", getName(), msg); + getLogger().warn(getName() + ": " + msg); } protected void error(String msg) { - getLogger().error("{}: {}", getName(), msg); + getLogger().error(getName() + ": " + msg); } protected void error(String msg, Throwable t) { - getLogger().error("{}: {}", getName(), msg, t); + getLogger().error(getName() + ": " + msg, t); } protected void info(String msg, Object... arguments) { - getLogger().info("{}: {}", getName(), msg, arguments); + getLogger().info(getName() + ": " + msg, arguments); } protected void debug(String msg, Object... arguments) { - getLogger().debug("{}: {}", getName(), msg, arguments); + getLogger().debug(getName() + ": " + msg, arguments); } protected void debug(Marker marker, String msg, Object... arguments) { - getLogger().debug(marker, "{}: {}", getName(), msg, arguments); + getLogger().debug(marker, getName() + ": " + msg, arguments); } protected abstract Logger getLogger(); diff --git a/core/src/test/java/org/nzbhydra/indexers/IndexerTest.java b/core/src/test/java/org/nzbhydra/indexers/IndexerTest.java index 911f293ee..34f2502c3 100644 --- a/core/src/test/java/org/nzbhydra/indexers/IndexerTest.java +++ b/core/src/test/java/org/nzbhydra/indexers/IndexerTest.java @@ -60,6 +60,7 @@ public class IndexerTest { + private Logger testLogger = LoggerFactory.getLogger("test"); private BaseConfig baseConfig; private IndexerEntity indexerEntityMock = new IndexerEntity("indexerName"); private IndexerConfig indexerConfig = new IndexerConfig(); @@ -109,7 +110,7 @@ private Indexer getTestee() { return new Indexer<>() { @Override protected Logger getLogger() { - return LoggerFactory.getLogger("test"); + return testLogger; } @@ -152,6 +153,7 @@ public void setUp() throws Exception { testee.indexer = indexerEntityMock; testee.config = indexerConfig; + indexerConfig.setName("testIndexer"); indexerConfig.setTimeout(1); baseConfig = new BaseConfig(); when(configProviderMock.getBaseConfig()).thenReturn(baseConfig); @@ -364,8 +366,11 @@ void shouldRemoveTrailing2() { testee.cleanUpTitle("abc trailing1 trailing2"); } System.out.println(stopwatch.elapsed(TimeUnit.MILLISECONDS)); + } - + @Test + public void shouldLogWithMessages() { + testee.info("Some message {}", "arg1"); }