Migrate server classes to Flogger
This is the second part of the migration to Flogger. This change migrates all classes of the 'server' module to Flogger. Classes of the 'httpd' module have been migrated by the predecessor change. Other modules continue to use slf4j. They should be migrated by follow-up changes. During this migration we try to make the log statements more consistent: - avoid string concatenation - avoid usage of String.format(...) Change-Id: I233afc8360af7fef8640394204d0d676cc0d0001 Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
@@ -20,6 +20,7 @@ import static org.pegdown.Extensions.HARDWRAPS;
|
||||
import static org.pegdown.Extensions.SUPPRESS_ALL_HTML;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -37,11 +38,9 @@ import org.pegdown.ast.HeaderNode;
|
||||
import org.pegdown.ast.Node;
|
||||
import org.pegdown.ast.RootNode;
|
||||
import org.pegdown.ast.TextNode;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class MarkdownFormatter {
|
||||
private static final Logger log = LoggerFactory.getLogger(MarkdownFormatter.class);
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private static final String defaultCss;
|
||||
|
||||
@@ -51,7 +50,7 @@ public class MarkdownFormatter {
|
||||
try {
|
||||
src = readPegdownCss(file);
|
||||
} catch (IOException err) {
|
||||
log.warn("Cannot load pegdown.css", err);
|
||||
logger.atWarning().withCause(err).log("Cannot load pegdown.css");
|
||||
src = "";
|
||||
}
|
||||
defaultCss = file.get() ? null : src;
|
||||
@@ -64,7 +63,7 @@ public class MarkdownFormatter {
|
||||
try {
|
||||
return readPegdownCss(new AtomicBoolean());
|
||||
} catch (IOException err) {
|
||||
log.warn("Cannot load pegdown.css", err);
|
||||
logger.atWarning().withCause(err).log("Cannot load pegdown.css");
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ package com.google.gerrit.server.documentation;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
@@ -36,12 +37,10 @@ import org.apache.lucene.search.TopDocs;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.store.IndexOutput;
|
||||
import org.apache.lucene.store.RAMDirectory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Singleton
|
||||
public class QueryDocumentationExecutor {
|
||||
private static final Logger log = LoggerFactory.getLogger(QueryDocumentationExecutor.class);
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private static Map<String, Float> WEIGHTS =
|
||||
ImmutableMap.of(
|
||||
@@ -70,7 +69,7 @@ public class QueryDocumentationExecutor {
|
||||
searcher = new IndexSearcher(reader);
|
||||
parser = new SimpleQueryParser(new StandardAnalyzer(), WEIGHTS);
|
||||
} catch (IOException e) {
|
||||
log.error("Cannot initialize documentation full text index", e);
|
||||
logger.atSevere().withCause(e).log("Cannot initialize documentation full text index");
|
||||
searcher = null;
|
||||
parser = null;
|
||||
}
|
||||
@@ -107,7 +106,7 @@ public class QueryDocumentationExecutor {
|
||||
byte[] buffer = new byte[4096];
|
||||
InputStream index = getClass().getResourceAsStream(Constants.INDEX_ZIP);
|
||||
if (index == null) {
|
||||
log.warn("No index available");
|
||||
logger.atWarning().log("No index available");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user