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

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