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

@ -16,7 +16,6 @@ package google.registry.module.frontend;
import com.google.appengine.api.LifecycleManager;
import com.google.common.flogger.FluentLogger;
import com.google.common.logging.FormattingLogger;
import com.google.monitoring.metrics.MetricReporter;
import dagger.Lazy;
import java.io.IOException;
@ -34,9 +33,7 @@ public final class FrontendServlet extends HttpServlet {
private static final FrontendComponent component = DaggerFrontendComponent.create();
private static final FrontendRequestHandler requestHandler = component.requestHandler();
private static final Lazy<MetricReporter> metricReporter = component.metricReporter();
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
// TODO(b/): Remove this static field.
private static final FluentLogger flogger = FluentLogger.forEnclosingClass();
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
@Override
public void init() {
@ -47,25 +44,25 @@ public final class FrontendServlet extends HttpServlet {
// registered if metric reporter starts up correctly.
try {
metricReporter.get().startAsync().awaitRunning(10, TimeUnit.SECONDS);
logger.info("Started up MetricReporter");
logger.atInfo().log("Started up MetricReporter");
LifecycleManager.getInstance()
.setShutdownHook(
() -> {
try {
metricReporter.get().stopAsync().awaitTerminated(10, TimeUnit.SECONDS);
logger.info("Shut down MetricReporter");
logger.atInfo().log("Shut down MetricReporter");
} catch (TimeoutException e) {
logger.severe(e, "Failed to stop MetricReporter.");
logger.atSevere().withCause(e).log("Failed to stop MetricReporter.");
}
});
} catch (Exception e) {
logger.severe(e, "Failed to initialize MetricReporter.");
logger.atSevere().withCause(e).log("Failed to initialize MetricReporter.");
}
}
@Override
public void service(HttpServletRequest req, HttpServletResponse rsp) throws IOException {
flogger.atInfo().log("Received frontend request");
logger.atInfo().log("Received frontend request");
requestHandler.handleRequest(req, rsp);
}
}