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

@ -13,6 +13,8 @@ java_library(
"//java/google/registry/util", "//java/google/registry/util",
"@com_google_code_findbugs_jsr305", "@com_google_code_findbugs_jsr305",
"@com_google_dagger", "@com_google_dagger",
"@com_google_flogger",
"@com_google_flogger_system_backend",
"@com_google_guava", "@com_google_guava",
"@org_bouncycastle_bcpg_jdk15on", "@org_bouncycastle_bcpg_jdk15on",
"@org_bouncycastle_bcpkix_jdk15on", "@org_bouncycastle_bcpkix_jdk15on",

View file

@ -16,7 +16,7 @@ package google.registry.keyring.api;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.MoreObjects; import com.google.common.base.MoreObjects;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import google.registry.util.ComparingInvocationHandler; import google.registry.util.ComparingInvocationHandler;
import java.io.IOException; import java.io.IOException;
import java.io.PrintWriter; import java.io.PrintWriter;
@ -43,8 +43,7 @@ import org.bouncycastle.openpgp.PGPPublicKey;
*/ */
public final class ComparatorKeyring extends ComparingInvocationHandler<Keyring> { public final class ComparatorKeyring extends ComparingInvocationHandler<Keyring> {
@VisibleForTesting private static final FluentLogger logger = FluentLogger.forEnclosingClass();
static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
private ComparatorKeyring(Keyring original, Keyring second) { private ComparatorKeyring(Keyring original, Keyring second) {
super(Keyring.class, original, second); super(Keyring.class, original, second);
@ -61,7 +60,7 @@ public final class ComparatorKeyring extends ComparingInvocationHandler<Keyring>
@Override @Override
protected void log(Method method, String message) { protected void log(Method method, String message) {
logger.severefmt("ComparatorKeyring.%s: %s", method.getName(), message); logger.atSevere().log("ComparatorKeyring.%s: %s", method.getName(), message);
} }
/** Implements equals for the PGP classes. */ /** Implements equals for the PGP classes. */
@ -124,7 +123,8 @@ public final class ComparatorKeyring extends ComparingInvocationHandler<Keyring>
return Arrays.equals(a.getFingerprint(), b.getFingerprint()) return Arrays.equals(a.getFingerprint(), b.getFingerprint())
&& Arrays.equals(a.getEncoded(), b.getEncoded()); && Arrays.equals(a.getEncoded(), b.getEncoded());
} catch (IOException e) { } catch (IOException e) {
logger.severe(e, "ComparatorKeyring error: PGPPublicKey.getEncoded failed."); logger.atSevere().withCause(e).log(
"ComparatorKeyring error: PGPPublicKey.getEncoded failed.");
return false; return false;
} }
} }
@ -147,7 +147,8 @@ public final class ComparatorKeyring extends ComparingInvocationHandler<Keyring>
try { try {
return Arrays.equals(a.getEncoded(), b.getEncoded()); return Arrays.equals(a.getEncoded(), b.getEncoded());
} catch (IOException e) { } catch (IOException e) {
logger.severe(e, "ComparatorKeyring error: PublicKeyPacket.getEncoded failed."); logger.atSevere().withCause(e).log(
"ComparatorKeyring error: PublicKeyPacket.getEncoded failed.");
return false; return false;
} }
} }

View file

@ -17,6 +17,8 @@ java_library(
"@com_google_appengine_tools_appengine_pipeline", "@com_google_appengine_tools_appengine_pipeline",
"@com_google_code_findbugs_jsr305", "@com_google_code_findbugs_jsr305",
"@com_google_dagger", "@com_google_dagger",
"@com_google_flogger",
"@com_google_flogger_system_backend",
"@com_google_guava", "@com_google_guava",
"@javax_servlet_api", "@javax_servlet_api",
"@joda_time", "@joda_time",

View file

@ -23,7 +23,6 @@ import com.google.appengine.tools.mapreduce.InputReader;
import com.google.appengine.tools.mapreduce.ShardContext; import com.google.appengine.tools.mapreduce.ShardContext;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.logging.FormattingLogger;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import com.googlecode.objectify.annotation.Entity; import com.googlecode.objectify.annotation.Entity;
import google.registry.model.EppResource; import google.registry.model.EppResource;
@ -42,8 +41,6 @@ class ChildEntityReader<R extends EppResource, I extends ImmutableObject> extend
private static final long serialVersionUID = 7481761146349663848L; private static final long serialVersionUID = 7481761146349663848L;
static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
/** This reader uses an EppResourceEntityReader under the covers to iterate over EPP resources. */ /** This reader uses an EppResourceEntityReader under the covers to iterate over EPP resources. */
private final EppResourceEntityReader<? extends R> eppResourceEntityReader; private final EppResourceEntityReader<? extends R> eppResourceEntityReader;

View file

@ -19,7 +19,6 @@ import static google.registry.model.ofy.ObjectifyService.ofy;
import com.google.appengine.api.datastore.Cursor; import com.google.appengine.api.datastore.Cursor;
import com.google.appengine.api.datastore.QueryResultIterator; import com.google.appengine.api.datastore.QueryResultIterator;
import com.google.appengine.tools.mapreduce.InputReader; import com.google.appengine.tools.mapreduce.InputReader;
import com.google.common.logging.FormattingLogger;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import com.googlecode.objectify.cmd.Query; import com.googlecode.objectify.cmd.Query;
import google.registry.model.ofy.CommitLogBucket; import google.registry.model.ofy.CommitLogBucket;
@ -32,8 +31,6 @@ import org.joda.time.DateTime;
class CommitLogManifestReader class CommitLogManifestReader
extends RetryingInputReader<Key<CommitLogManifest>, Key<CommitLogManifest>> { extends RetryingInputReader<Key<CommitLogManifest>, Key<CommitLogManifest>> {
static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
/** /**
* Memory estimation for this reader. * Memory estimation for this reader.
* *

View file

@ -21,7 +21,6 @@ import com.google.appengine.api.datastore.Cursor;
import com.google.appengine.api.datastore.QueryResultIterator; import com.google.appengine.api.datastore.QueryResultIterator;
import com.google.appengine.tools.mapreduce.InputReader; import com.google.appengine.tools.mapreduce.InputReader;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.logging.FormattingLogger;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import com.googlecode.objectify.cmd.Query; import com.googlecode.objectify.cmd.Query;
import google.registry.model.EppResource; import google.registry.model.EppResource;
@ -32,8 +31,6 @@ import javax.annotation.Nullable;
/** Base class for {@link InputReader} classes that map over {@link EppResourceIndex}. */ /** Base class for {@link InputReader} classes that map over {@link EppResourceIndex}. */
abstract class EppResourceBaseReader<T> extends RetryingInputReader<EppResourceIndex, T> { abstract class EppResourceBaseReader<T> extends RetryingInputReader<EppResourceIndex, T> {
static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
/** Number of bytes in 1MB of memory, used for memory estimates. */ /** Number of bytes in 1MB of memory, used for memory estimates. */
static final long ONE_MB = 1024 * 1024; static final long ONE_MB = 1024 * 1024;

View file

@ -18,6 +18,7 @@ import static google.registry.model.ofy.ObjectifyService.ofy;
import com.google.appengine.tools.mapreduce.InputReader; import com.google.appengine.tools.mapreduce.InputReader;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.flogger.FluentLogger;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import google.registry.model.EppResource; import google.registry.model.EppResource;
import google.registry.model.index.EppResourceIndex; import google.registry.model.index.EppResourceIndex;
@ -27,6 +28,8 @@ import java.util.NoSuchElementException;
/** Reader that maps over {@link EppResourceIndex} and returns resources. */ /** Reader that maps over {@link EppResourceIndex} and returns resources. */
class EppResourceEntityReader<R extends EppResource> extends EppResourceBaseReader<R> { class EppResourceEntityReader<R extends EppResource> extends EppResourceBaseReader<R> {
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
private static final long serialVersionUID = -8042933349899971801L; private static final long serialVersionUID = -8042933349899971801L;
/** /**
@ -61,7 +64,7 @@ class EppResourceEntityReader<R extends EppResource> extends EppResourceBaseRead
Key<? extends EppResource> key = nextQueryResult().getKey(); Key<? extends EppResource> key = nextQueryResult().getKey();
EppResource resource = ofy().load().key(key).now(); EppResource resource = ofy().load().key(key).now();
if (resource == null) { if (resource == null) {
logger.severefmt("EppResourceIndex key %s points at a missing resource", key); logger.atSevere().log("EppResourceIndex key %s points at a missing resource", key);
continue; continue;
} }
// Postfilter to distinguish polymorphic types (e.g. DomainBase and DomainResource). // Postfilter to distinguish polymorphic types (e.g. DomainBase and DomainResource).

View file

@ -31,6 +31,8 @@ java_library(
"@com_google_appengine_api_1_0_sdk", "@com_google_appengine_api_1_0_sdk",
"@com_google_code_findbugs_jsr305", "@com_google_code_findbugs_jsr305",
"@com_google_dagger", "@com_google_dagger",
"@com_google_flogger",
"@com_google_flogger_system_backend",
"@com_google_guava", "@com_google_guava",
"@com_google_re2j", "@com_google_re2j",
"@io_bazel_rules_closure//closure/templates", "@io_bazel_rules_closure//closure/templates",

View file

@ -21,7 +21,7 @@ import static google.registry.util.PreconditionsUtils.checkArgumentPresent;
import com.google.appengine.api.users.User; import com.google.appengine.api.users.User;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import google.registry.config.RegistryConfig.Config; import google.registry.config.RegistryConfig.Config;
import google.registry.model.registrar.Registrar; import google.registry.model.registrar.Registrar;
@ -40,7 +40,7 @@ import javax.servlet.http.HttpSession;
@Immutable @Immutable
public class SessionUtils { public class SessionUtils {
static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
public static final String CLIENT_ID_ATTRIBUTE = "clientId"; public static final String CLIENT_ID_ATTRIBUTE = "clientId";
@ -102,11 +102,12 @@ public class SessionUtils {
// Use the clientId if it exists // Use the clientId if it exists
if (clientId != null) { if (clientId != null) {
if (!hasAccessToRegistrar(clientId, user.getUserId())) { if (!hasAccessToRegistrar(clientId, user.getUserId())) {
logger.infofmt("Registrar Console access revoked: %s", clientId); logger.atInfo().log("Registrar Console access revoked: %s", clientId);
session.invalidate(); session.invalidate();
return false; return false;
} }
logger.infofmt("Associating user %s with given registrar %s.", user.getUserId(), clientId); logger.atInfo().log(
"Associating user %s with given registrar %s.", user.getUserId(), clientId);
return true; return true;
} }
@ -114,7 +115,7 @@ public class SessionUtils {
Optional<Registrar> registrar = findRegistrarForUser(user.getUserId()); Optional<Registrar> registrar = findRegistrarForUser(user.getUserId());
if (registrar.isPresent()) { if (registrar.isPresent()) {
verify(hasAccessToRegistrar(registrar.get(), user.getUserId())); verify(hasAccessToRegistrar(registrar.get(), user.getUserId()));
logger.infofmt( logger.atInfo().log(
"Associating user %s with found registrar %s.", "Associating user %s with found registrar %s.",
user.getUserId(), registrar.get().getClientId()); user.getUserId(), registrar.get().getClientId());
session.setAttribute(CLIENT_ID_ATTRIBUTE, registrar.get().getClientId()); session.setAttribute(CLIENT_ID_ATTRIBUTE, registrar.get().getClientId());
@ -125,20 +126,20 @@ public class SessionUtils {
// registryAdminClientId // registryAdminClientId
if (userAuthInfo.isUserAdmin()) { if (userAuthInfo.isUserAdmin()) {
if (Strings.isNullOrEmpty(registryAdminClientId)) { if (Strings.isNullOrEmpty(registryAdminClientId)) {
logger.infofmt( logger.atInfo().log(
"Cannot associate admin user %s with configured client Id." "Cannot associate admin user %s with configured client Id."
+ " ClientId is null or empty.", + " ClientId is null or empty.",
user.getUserId()); user.getUserId());
return false; return false;
} }
if (!Registrar.loadByClientIdCached(registryAdminClientId).isPresent()) { if (!Registrar.loadByClientIdCached(registryAdminClientId).isPresent()) {
logger.infofmt( logger.atInfo().log(
"Cannot associate admin user %s with configured client Id %s." "Cannot associate admin user %s with configured client Id %s."
+ " Registrar does not exist.", + " Registrar does not exist.",
user.getUserId(), registryAdminClientId); user.getUserId(), registryAdminClientId);
return false; return false;
} }
logger.infofmt( logger.atInfo().log(
"User %s is an admin with no associated registrar." "User %s is an admin with no associated registrar."
+ " Automatically associating the user with configured client Id %s.", + " Automatically associating the user with configured client Id %s.",
user.getUserId(), registryAdminClientId); user.getUserId(), registryAdminClientId);
@ -147,7 +148,7 @@ public class SessionUtils {
} }
// We couldn't find any relevant clientId // We couldn't find any relevant clientId
logger.infofmt("User not associated with any Registrar: %s", user.getUserId()); logger.atInfo().log("User not associated with any Registrar: %s", user.getUserId());
return false; return false;
} }
@ -173,7 +174,7 @@ public class SessionUtils {
String registrarClientId = contact.getParent().getName(); String registrarClientId = contact.getParent().getName();
Optional<Registrar> result = Registrar.loadByClientIdCached(registrarClientId); Optional<Registrar> result = Registrar.loadByClientIdCached(registrarClientId);
if (!result.isPresent()) { if (!result.isPresent()) {
logger.severefmt( logger.atSevere().log(
"A contact record exists for non-existent registrar: %s.", Key.create(contact)); "A contact record exists for non-existent registrar: %s.", Key.create(contact));
} }
return result; return result;
@ -183,7 +184,7 @@ public class SessionUtils {
protected static boolean hasAccessToRegistrar(String clientId, final String gaeUserId) { protected static boolean hasAccessToRegistrar(String clientId, final String gaeUserId) {
Optional<Registrar> registrar = Registrar.loadByClientIdCached(clientId); Optional<Registrar> registrar = Registrar.loadByClientIdCached(clientId);
if (!registrar.isPresent()) { if (!registrar.isPresent()) {
logger.warningfmt("Registrar '%s' disappeared from Datastore!", clientId); logger.atWarning().log("Registrar '%s' disappeared from Datastore!", clientId);
return false; return false;
} }
return hasAccessToRegistrar(registrar.get(), gaeUserId); return hasAccessToRegistrar(registrar.get(), gaeUserId);

View file

@ -15,6 +15,8 @@ java_library(
"@com_google_code_findbugs_jsr305", "@com_google_code_findbugs_jsr305",
"@com_google_dagger", "@com_google_dagger",
"@com_google_errorprone_error_prone_annotations", "@com_google_errorprone_error_prone_annotations",
"@com_google_flogger",
"@com_google_flogger_system_backend",
"@com_google_guava", "@com_google_guava",
"@com_google_re2j", "@com_google_re2j",
"@com_ibm_icu_icu4j", "@com_ibm_icu_icu4j",

View file

@ -22,7 +22,7 @@ import com.google.apphosting.api.ApiProxy;
import com.google.apphosting.api.ApiProxy.Environment; import com.google.apphosting.api.ApiProxy.Environment;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.logging.FormattingLogger; import com.google.common.flogger.FluentLogger;
import java.util.Collections; import java.util.Collections;
import javax.inject.Inject; import javax.inject.Inject;
@ -31,8 +31,7 @@ public class RequestStatusCheckerImpl implements RequestStatusChecker {
private static final long serialVersionUID = -8161977032130865437L; private static final long serialVersionUID = -8161977032130865437L;
@VisibleForTesting private static final FluentLogger logger = FluentLogger.forEnclosingClass();
static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
@VisibleForTesting @VisibleForTesting
static LogService logService = LogServiceFactory.getLogService(); static LogService logService = LogServiceFactory.getLogService();
@ -56,7 +55,7 @@ public class RequestStatusCheckerImpl implements RequestStatusChecker {
public String getLogId() { public String getLogId() {
String requestLogId = String requestLogId =
ApiProxy.getCurrentEnvironment().getAttributes().get(REQUEST_LOG_ID_KEY).toString(); ApiProxy.getCurrentEnvironment().getAttributes().get(REQUEST_LOG_ID_KEY).toString();
logger.infofmt("Current requestLogId: %s", requestLogId); logger.atInfo().log("Current requestLogId: %s", requestLogId);
// We want to make sure there actually is a log to query for this request, even if the request // We want to make sure there actually is a log to query for this request, even if the request
// dies right after this call. // dies right after this call.
// //
@ -85,12 +84,12 @@ public class RequestStatusCheckerImpl implements RequestStatusChecker {
// request is too new (it can take several seconds until the logs are available for "fetch"). // request is too new (it can take several seconds until the logs are available for "fetch").
// So we have to assume it's "running" in that case. // So we have to assume it's "running" in that case.
if (requestLogs == null) { if (requestLogs == null) {
logger.infofmt( logger.atInfo().log(
"Queried an unrecognized requestLogId %s - assume it's running", requestLogId); "Queried an unrecognized requestLogId %s - assume it's running", requestLogId);
return true; return true;
} }
logger.infofmt( logger.atInfo().log(
"Found logs for requestLogId %s - isFinished: %s", requestLogId, requestLogs.isFinished()); "Found logs for requestLogId %s - isFinished: %b", requestLogId, requestLogs.isFinished());
return !requestLogs.isFinished(); return !requestLogs.isFinished();
} }
} }

View file

@ -20,6 +20,8 @@ java_library(
"@com_google_auto_value", "@com_google_auto_value",
"@com_google_code_findbugs_jsr305", "@com_google_code_findbugs_jsr305",
"@com_google_dagger", "@com_google_dagger",
"@com_google_flogger",
"@com_google_flogger_system_backend",
"@com_google_guava", "@com_google_guava",
"@com_google_monitoring_client_metrics", "@com_google_monitoring_client_metrics",
"@javax_servlet_api", "@javax_servlet_api",

View file

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

View file

@ -13,6 +13,8 @@ java_library(
deps = [ deps = [
"//java/google/registry/keyring/api", "//java/google/registry/keyring/api",
"//javatests/google/registry/testing", "//javatests/google/registry/testing",
"@com_google_flogger",
"@com_google_flogger_system_backend",
"@com_google_guava_testlib", "@com_google_guava_testlib",
"@com_google_truth", "@com_google_truth",
"@com_google_truth_extensions_truth_java8_extension", "@com_google_truth_extensions_truth_java8_extension",

View file

@ -21,6 +21,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import com.google.common.flogger.LoggerConfig;
import com.google.common.testing.TestLogHandler; import com.google.common.testing.TestLogHandler;
import java.io.IOException; import java.io.IOException;
import java.util.logging.Level; import java.util.logging.Level;
@ -80,12 +81,12 @@ public class ComparatorKeyringTest {
@Before @Before
public void setUp() { public void setUp() {
ComparatorKeyring.logger.getFormattingLogger().addHandler(testLogHandler); LoggerConfig.getConfig(ComparatorKeyring.class).addHandler(testLogHandler);
} }
@After @After
public void tearDown() { public void tearDown() {
ComparatorKeyring.logger.getFormattingLogger().removeHandler(testLogHandler); LoggerConfig.getConfig(ComparatorKeyring.class).removeHandler(testLogHandler);
} }
@Test @Test

View file

@ -27,6 +27,8 @@ java_library(
"//third_party/objectify:objectify-v4_1", "//third_party/objectify:objectify-v4_1",
"@com_braintreepayments_gateway_braintree_java", "@com_braintreepayments_gateway_braintree_java",
"@com_google_appengine_api_1_0_sdk//:testonly", "@com_google_appengine_api_1_0_sdk//:testonly",
"@com_google_flogger",
"@com_google_flogger_system_backend",
"@com_google_guava", "@com_google_guava",
"@com_google_guava_testlib", "@com_google_guava_testlib",
"@com_google_truth", "@com_google_truth",

View file

@ -28,6 +28,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import com.google.appengine.api.users.User; import com.google.appengine.api.users.User;
import com.google.common.flogger.LoggerConfig;
import com.google.common.testing.NullPointerTester; import com.google.common.testing.NullPointerTester;
import com.google.common.testing.TestLogHandler; import com.google.common.testing.TestLogHandler;
import google.registry.model.registrar.RegistrarContact; import google.registry.model.registrar.RegistrarContact;
@ -77,7 +78,7 @@ public class SessionUtilsTest {
@Before @Before
public void before() throws Exception { public void before() throws Exception {
SessionUtils.logger.getFormattingLogger().addHandler(testLogHandler); LoggerConfig.getConfig(SessionUtils.class).addHandler(testLogHandler);
sessionUtils = new SessionUtils(); sessionUtils = new SessionUtils();
sessionUtils.registryAdminClientId = ADMIN_CLIENT_ID; sessionUtils.registryAdminClientId = ADMIN_CLIENT_ID;
persistResource(loadRegistrar(ADMIN_CLIENT_ID)); persistResource(loadRegistrar(ADMIN_CLIENT_ID));
@ -86,7 +87,7 @@ public class SessionUtilsTest {
@After @After
public void after() throws Exception { public void after() throws Exception {
SessionUtils.logger.getFormattingLogger().removeHandler(testLogHandler); LoggerConfig.getConfig(SessionUtils.class).removeHandler(testLogHandler);
} }
/** User needs to be logged in before calling checkRegistrarConsoleLogin */ /** User needs to be logged in before calling checkRegistrarConsoleLogin */

View file

@ -16,6 +16,8 @@ java_library(
"//javatests/google/registry/testing", "//javatests/google/registry/testing",
"@com_google_appengine_api_1_0_sdk", "@com_google_appengine_api_1_0_sdk",
"@com_google_code_findbugs_jsr305", "@com_google_code_findbugs_jsr305",
"@com_google_flogger",
"@com_google_flogger_system_backend",
"@com_google_guava", "@com_google_guava",
"@com_google_guava_testlib", "@com_google_guava_testlib",
"@com_google_re2j", "@com_google_re2j",

View file

@ -25,6 +25,7 @@ import com.google.appengine.api.log.LogService;
import com.google.appengine.api.log.RequestLogs; import com.google.appengine.api.log.RequestLogs;
import com.google.apphosting.api.ApiProxy; import com.google.apphosting.api.ApiProxy;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.flogger.LoggerConfig;
import com.google.common.testing.TestLogHandler; import com.google.common.testing.TestLogHandler;
import google.registry.testing.AppEngineRule; import google.registry.testing.AppEngineRule;
import java.util.logging.Level; import java.util.logging.Level;
@ -69,12 +70,12 @@ public final class RequestStatusCheckerImplTest {
public AppEngineRule appEngineRule = AppEngineRule.builder().build(); public AppEngineRule appEngineRule = AppEngineRule.builder().build();
@Before public void setUp() { @Before public void setUp() {
RequestStatusCheckerImpl.logger.getFormattingLogger().addHandler(logHandler); LoggerConfig.getConfig(RequestStatusCheckerImpl.class).addHandler(logHandler);
RequestStatusCheckerImpl.logService = mock(LogService.class); RequestStatusCheckerImpl.logService = mock(LogService.class);
} }
@After public void tearDown() { @After public void tearDown() {
RequestStatusCheckerImpl.logger.getFormattingLogger().removeHandler(logHandler); LoggerConfig.getConfig(RequestStatusCheckerImpl.class).removeHandler(logHandler);
} }
// If a logId is unrecognized, it could be that the log hasn't been uploaded yet - so we assume // If a logId is unrecognized, it could be that the log hasn't been uploaded yet - so we assume

View file

@ -22,6 +22,8 @@ java_library(
"@com_google_appengine_api_1_0_sdk", "@com_google_appengine_api_1_0_sdk",
"@com_google_appengine_testing", "@com_google_appengine_testing",
"@com_google_dagger", "@com_google_dagger",
"@com_google_flogger",
"@com_google_flogger_system_backend",
"@com_google_guava", "@com_google_guava",
"@com_google_guava_testlib", "@com_google_guava_testlib",
"@com_google_truth", "@com_google_truth",

View file

@ -19,6 +19,7 @@ import static google.registry.testing.DatastoreHelper.createTlds;
import static google.registry.testing.JUnitBackports.assertThrows; import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.testing.LogsSubject.assertAboutLogs; import static google.registry.testing.LogsSubject.assertAboutLogs;
import com.google.common.flogger.LoggerConfig;
import com.google.common.testing.TestLogHandler; import com.google.common.testing.TestLogHandler;
import google.registry.testing.AppEngineRule; import google.registry.testing.AppEngineRule;
import google.registry.testing.FakeClock; import google.registry.testing.FakeClock;
@ -41,7 +42,7 @@ public class WhoisReaderTest {
@Before @Before
public void init() { public void init() {
createTlds("tld", "xn--kgbechtv", "1.test"); createTlds("tld", "xn--kgbechtv", "1.test");
WhoisReader.logger.getFormattingLogger().addHandler(testLogHandler); LoggerConfig.getConfig(WhoisReader.class).addHandler(testLogHandler);
} }
@SuppressWarnings({"TypeParameterUnusedInFormals", "unchecked"}) @SuppressWarnings({"TypeParameterUnusedInFormals", "unchecked"})