Migrate to Flogger (yellow)

This is a 'yellow' Flogger migration CL. Yellow CLs should be mostly safe
but include changes that are notable for one reason or another. Manual
intervention may be required to address small issues.

The comments in this CL indicate cases where suggested code changes
should be double checked, or even modified. There may even be cases where
files outside this CL are affected by changes to things such as logger
visibility. However if a change does not have an associated comment then
it should be safe.

For more information, see []
Base CL: 197826149

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=198097990
This commit is contained in:
jianglai 2018-05-25 13:56:19 -07:00
parent 92190f8699
commit 4be4fb0082
21 changed files with 69 additions and 52 deletions

View file

@ -21,8 +21,8 @@ import static google.registry.util.DomainNameUtils.canonicalizeDomainName;
import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
import com.google.common.base.Joiner;
import com.google.common.flogger.FluentLogger;
import com.google.common.io.CharStreams;
import com.google.common.logging.FormattingLogger;
import com.google.common.net.InetAddresses;
import com.google.common.net.InternetDomainName;
import google.registry.config.RegistryConfig.Config;
@ -63,7 +63,7 @@ import org.joda.time.DateTime;
*/
class WhoisReader {
static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
/**
* These are strings that will always trigger a specific query type when they are sent at
@ -115,7 +115,7 @@ class WhoisReader {
// Try to parse the argument as a domain name.
try {
logger.infofmt("Attempting domain lookup command using domain name %s", tokens.get(1));
logger.atInfo().log("Attempting domain lookup command using domain name %s", tokens.get(1));
return commandFactory.domainLookup(
InternetDomainName.from(canonicalizeDomainName(tokens.get(1))), fullOutput);
} catch (IllegalArgumentException iae) {
@ -134,7 +134,7 @@ class WhoisReader {
// Try to parse the argument as an IP address.
try {
logger.infofmt(
logger.atInfo().log(
"Attempting nameserver lookup command using %s as an IP address", tokens.get(1));
return commandFactory.nameserverLookupByIp(InetAddresses.forString(tokens.get(1)));
} catch (IllegalArgumentException iae) {
@ -143,7 +143,7 @@ class WhoisReader {
// Try to parse the argument as a host name.
try {
logger.infofmt(
logger.atInfo().log(
"Attempting nameserver lookup command using %s as a hostname", tokens.get(1));
return commandFactory.nameserverLookupByHost(InternetDomainName.from(
canonicalizeDomainName(tokens.get(1))));
@ -163,7 +163,7 @@ class WhoisReader {
"Too few arguments to '%s' command.", REGISTRAR_LOOKUP_COMMAND));
}
String registrarLookupArgument = Joiner.on(' ').join(tokens.subList(1, tokens.size()));
logger.infofmt(
logger.atInfo().log(
"Attempting registrar lookup command using registrar %s", registrarLookupArgument);
return commandFactory.registrarLookup(registrarLookupArgument);
}
@ -172,7 +172,7 @@ class WhoisReader {
if (tokens.size() == 1) {
// Try to parse it as an IP address. If successful, then this is a lookup on a nameserver.
try {
logger.infofmt("Attempting nameserver lookup using %s as an IP address", arg1);
logger.atInfo().log("Attempting nameserver lookup using %s as an IP address", arg1);
return commandFactory.nameserverLookupByIp(InetAddresses.forString(arg1));
} catch (IllegalArgumentException iae) {
// Silently ignore this exception.
@ -187,19 +187,19 @@ class WhoisReader {
Optional<InternetDomainName> tld = findTldForName(targetName);
if (!tld.isPresent()) {
// This target is not under any configured TLD, so just try it as a registrar name.
logger.infofmt("Attempting registrar lookup using %s as a registrar", arg1);
logger.atInfo().log("Attempting registrar lookup using %s as a registrar", arg1);
return new RegistrarLookupCommand(arg1);
}
// If the target is exactly one level above the TLD, then this is a second level domain
// (SLD) and we should do a domain lookup on it.
if (targetName.parent().equals(tld.get())) {
logger.infofmt("Attempting domain lookup using %s as a domain name", targetName);
logger.atInfo().log("Attempting domain lookup using %s as a domain name", targetName);
return commandFactory.domainLookup(targetName, fullOutput);
}
// The target is more than one level above the TLD, so we'll assume it's a nameserver.
logger.infofmt("Attempting nameserver lookup using %s as a hostname", targetName);
logger.atInfo().log("Attempting nameserver lookup using %s as a hostname", targetName);
return commandFactory.nameserverLookupByHost(targetName);
} catch (IllegalArgumentException e) {
// Silently ignore this exception.
@ -211,7 +211,7 @@ class WhoisReader {
// The only case left is that there are multiple tokens with no particular command given. We'll
// assume this is a registrar lookup, since there's really nothing else it could be.
String registrarLookupArgument = Joiner.on(' ').join(tokens);
logger.infofmt(
logger.atInfo().log(
"Attempting registrar lookup employing %s as a registrar", registrarLookupArgument);
return commandFactory.registrarLookup(registrarLookupArgument);
}