Migrate to Flogger (green)

This is a 'green' Flogger migration CL. Green CLs are intended to be as
safe as possible and should be easy to review and submit.

No changes should be necessary to the code itself prior to submission,
but small changes to BUILD files may be required.

Changes within files are completely independent of each other, so this CL
can be safely split up for review using tools such as Rosie.

For more information, see []
Base CL: 197826149

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=198560170
This commit is contained in:
jianglai 2018-05-30 07:58:51 -07:00
parent 0d2fb3a8f0
commit 70b13596e4
178 changed files with 984 additions and 988 deletions

View file

@ -8,7 +8,6 @@ java_library(
name = "whois",
srcs = glob(["*.java"]),
deps = [
"//java/com/google/common/logging:formatting_logger",
"//java/google/registry/config",
"//java/google/registry/model",
"//java/google/registry/request",

View file

@ -21,7 +21,7 @@ import static google.registry.xml.UtcDateTimeAdapter.getFormattedString;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.logging.FormattingLogger;
import com.google.common.flogger.FluentLogger;
import com.googlecode.objectify.Key;
import google.registry.model.EppResource;
import google.registry.model.contact.ContactPhoneNumber;
@ -44,7 +44,7 @@ import org.joda.time.DateTime;
/** Represents a WHOIS response to a domain query. */
final class DomainWhoisResponse extends WhoisResponseImpl {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
/** Prefix for status value URLs. */
private static final String ICANN_STATUS_URL_PREFIX = "https://icann.org/epp#";
@ -158,7 +158,7 @@ final class DomainWhoisResponse extends WhoisResponseImpl {
// someone's attention.
ContactResource contactResource = EppResource.loadCached(contact.get());
if (contactResource == null) {
logger.severefmt(
logger.atSevere().log(
"(BUG) Broken reference found from domain %s to contact %s",
domain.getFullyQualifiedDomainName(), contact);
return this;

View file

@ -27,7 +27,7 @@ import com.google.common.base.Splitter;
import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.logging.FormattingLogger;
import com.google.common.flogger.FluentLogger;
import google.registry.model.registrar.Registrar;
import java.util.HashMap;
import java.util.List;
@ -37,7 +37,7 @@ import org.joda.time.DateTime;
/** Represents a WHOIS lookup for a registrar by its name. */
final class RegistrarLookupCommand implements WhoisCommand {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
/**
* Cache of a map from a stripped-down (letters and digits only) name to the registrar. This map
@ -56,7 +56,7 @@ final class RegistrarLookupCommand implements WhoisCommand {
}
String normalized = normalizeRegistrarName(registrar.getRegistrarName());
if (map.put(normalized, registrar) != null) {
logger.warningfmt(
logger.atWarning().log(
"%s appeared as a normalized registrar name for more than one registrar.",
normalized);
}

View file

@ -20,7 +20,7 @@ import static javax.servlet.http.HttpServletResponse.SC_OK;
import com.google.appengine.api.datastore.DatastoreFailureException;
import com.google.appengine.api.datastore.DatastoreTimeoutException;
import com.google.common.logging.FormattingLogger;
import com.google.common.flogger.FluentLogger;
import com.google.common.net.MediaType;
import google.registry.config.RegistryConfig.Config;
import google.registry.request.Action;
@ -52,7 +52,7 @@ import org.joda.time.DateTime;
@Action(path = "/_dr/whois", method = POST, auth = Auth.AUTH_PUBLIC_OR_INTERNAL)
public class WhoisAction implements Runnable {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
/** WHOIS doesn't define an encoding, nor any way to specify an encoding in the protocol. */
static final MediaType CONTENT_TYPE = MediaType.PLAIN_TEXT_UTF_8;
@ -107,7 +107,7 @@ public class WhoisAction implements Runnable {
responseText = results.plainTextOutput();
setWhoisMetrics(metricBuilder, 0, e.getStatus());
} catch (Throwable t) {
logger.severe(t, "WHOIS request crashed");
logger.atSevere().withCause(t).log("WHOIS request crashed");
responseText = "Internal Server Error";
setWhoisMetrics(metricBuilder, 0, SC_INTERNAL_SERVER_ERROR);
}

View file

@ -28,7 +28,7 @@ import static javax.servlet.http.HttpServletResponse.SC_OK;
import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
import com.google.common.logging.FormattingLogger;
import com.google.common.flogger.FluentLogger;
import google.registry.config.RegistryConfig.Config;
import google.registry.request.Action;
import google.registry.request.RequestPath;
@ -100,7 +100,7 @@ public final class WhoisHttpAction implements Runnable {
public static final String PATH = "/whois/";
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
/**
* Cross-origin resource sharing (CORS) allowed origins policy.
@ -187,7 +187,7 @@ public final class WhoisHttpAction implements Runnable {
try {
return URLDecoder.decode(pathData, "UTF-8");
} catch (IllegalArgumentException e) {
logger.infofmt("Malformed WHOIS request path: %s (%s)", requestPath, pathData);
logger.atInfo().log("Malformed WHOIS request path: %s (%s)", requestPath, pathData);
throw new WhoisException(clock.nowUtc(), SC_BAD_REQUEST, "Malformed path query.");
}
}