Migrating to fluent logging (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: 197331037

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=197466715
This commit is contained in:
jianglai 2018-05-21 15:08:53 -07:00
parent 3983f32795
commit 05f166918f
12 changed files with 64 additions and 78 deletions

View file

@ -16,7 +16,7 @@ package google.registry.proxy.handler;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.logging.FormattingLogger;
import com.google.common.flogger.FluentLogger;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandlerContext;
@ -33,7 +33,7 @@ import javax.inject.Inject;
*/
public class RelayHandler<I> extends SimpleChannelInboundHandler<I> {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
/** Key used to retrieve the relay channel from a {@link Channel}'s {@link Attribute}. */
public static final AttributeKey<Channel> RELAY_CHANNEL_KEY =
@ -46,7 +46,8 @@ public class RelayHandler<I> extends SimpleChannelInboundHandler<I> {
/** Terminate connection when an exception is caught during inbound IO. */
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
logger.severefmt(cause, "Inbound exception caught for channel %s", ctx.channel());
logger.atSevere().withCause(cause).log(
"Inbound exception caught for channel %s", ctx.channel());
ChannelFuture unusedFuture = ctx.close();
}