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

@ -13,7 +13,6 @@ java_library(
"*.asc",
]),
deps = [
"//java/com/google/common/logging:formatting_logger",
"//java/google/registry/config",
"//java/google/registry/keyring/api",
"//java/google/registry/model",
@ -25,6 +24,8 @@ java_library(
"@com_google_appengine_api_1_0_sdk",
"@com_google_code_findbugs_jsr305",
"@com_google_dagger",
"@com_google_flogger",
"@com_google_flogger_system_backend",
"@com_google_guava",
"@com_google_re2j",
"@javax_servlet_api",

View file

@ -34,7 +34,7 @@ import com.google.appengine.api.taskqueue.TaskOptions;
import com.google.appengine.api.urlfetch.HTTPRequest;
import com.google.appengine.api.urlfetch.HTTPResponse;
import com.google.appengine.api.urlfetch.URLFetchService;
import com.google.common.logging.FormattingLogger;
import com.google.common.flogger.FluentLogger;
import google.registry.config.RegistryConfig.Config;
import google.registry.request.Action;
import google.registry.request.Parameter;
@ -70,7 +70,7 @@ public final class NordnUploadAction implements Runnable {
static final String PATH = "/_dr/task/nordnUpload";
static final String LORDN_PHASE_PARAM = "lordn-phase";
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
/**
* A unique (enough) id that is outputted in log lines to make it clear which log lines are
@ -134,13 +134,14 @@ public final class NordnUploadAction implements Runnable {
*/
private void uploadCsvToLordn(String urlPath, String csvData) throws IOException {
String url = tmchMarksdbUrl + urlPath;
logger.infofmt("LORDN upload task %s: Sending to URL: %s ; data: %s",
actionLogId, url, csvData);
logger.atInfo().log(
"LORDN upload task %s: Sending to URL: %s ; data: %s", actionLogId, url, csvData);
HTTPRequest req = new HTTPRequest(new URL(url), POST, validateCertificate().setDeadline(60d));
lordnRequestInitializer.initialize(req, tld);
setPayloadMultipart(req, "file", "claims.csv", CSV_UTF_8, csvData);
HTTPResponse rsp = fetchService.fetch(req);
logger.infofmt("LORDN upload task %s response: HTTP response code %d, response data: %s",
logger.atInfo().log(
"LORDN upload task %s response: HTTP response code %d, response data: %s",
actionLogId, rsp.getResponseCode(), rsp.getContent());
if (rsp.getResponseCode() != SC_ACCEPTED) {
throw new UrlFetchException(

View file

@ -24,8 +24,8 @@ import com.google.appengine.api.urlfetch.HTTPRequest;
import com.google.appengine.api.urlfetch.HTTPResponse;
import com.google.appengine.api.urlfetch.URLFetchService;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.flogger.FluentLogger;
import com.google.common.io.ByteSource;
import com.google.common.logging.FormattingLogger;
import google.registry.request.Action;
import google.registry.request.Header;
import google.registry.request.HttpException.ConflictException;
@ -64,7 +64,7 @@ public final class NordnVerifyAction implements Runnable {
static final String URL_HEADER = "X-DomainRegistry-Nordn-Url";
static final String HEADER_ACTION_LOG_ID = "X-DomainRegistry-ActionLogId";
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
@Inject LordnRequestInitializer lordnRequestInitializer;
@Inject Response response;
@ -95,11 +95,12 @@ public final class NordnVerifyAction implements Runnable {
*/
@VisibleForTesting
LordnLog verify() throws IOException {
logger.infofmt("LORDN verify task %s: Sending request to URL %s.", actionLogId, url);
logger.atInfo().log("LORDN verify task %s: Sending request to URL %s.", actionLogId, url);
HTTPRequest req = new HTTPRequest(url, GET, validateCertificate().setDeadline(60d));
lordnRequestInitializer.initialize(req, tld);
HTTPResponse rsp = fetchService.fetch(req);
logger.infofmt("LORDN verify task %s response: HTTP response code %d, response data: %s",
logger.atInfo().log(
"LORDN verify task %s response: HTTP response code %d, response data: %s",
actionLogId, rsp.getResponseCode(), rsp.getContent());
if (rsp.getResponseCode() == SC_NO_CONTENT) {
// Send a 400+ status code so App Engine will retry the task.
@ -114,9 +115,10 @@ public final class NordnVerifyAction implements Runnable {
LordnLog log =
LordnLog.parse(ByteSource.wrap(rsp.getContent()).asCharSource(UTF_8).readLines());
if (log.getStatus() == LordnLog.Status.ACCEPTED) {
logger.infofmt("LORDN verify task %s: Upload accepted", actionLogId);
logger.atInfo().log("LORDN verify task %s: Upload accepted", actionLogId);
} else {
logger.severefmt("LORDN verify task %s: Upload rejected with reason: %s", actionLogId, log);
logger.atSevere().log(
"LORDN verify task %s: Upload rejected with reason: %s", actionLogId, log);
}
for (Entry<String, LordnLog.Result> result : log) {
switch (result.getValue().getOutcome()) {
@ -125,11 +127,11 @@ public final class NordnVerifyAction implements Runnable {
case WARNING:
// fall through
case ERROR:
logger.warning(result.toString());
logger.atWarning().log(result.toString());
break;
default:
logger.warningfmt(
"LORDN verify task %s: Unexpected outcome: %s", actionLogId, result.toString());
logger.atWarning().log(
"LORDN verify task %s: Unexpected outcome: %s", actionLogId, result);
break;
}
}

View file

@ -16,7 +16,7 @@ package google.registry.tmch;
import static google.registry.request.Action.Method.POST;
import com.google.common.logging.FormattingLogger;
import com.google.common.flogger.FluentLogger;
import google.registry.keyring.api.KeyModule.Key;
import google.registry.model.tmch.ClaimsListShard;
import google.registry.request.Action;
@ -37,7 +37,7 @@ import org.bouncycastle.openpgp.PGPException;
)
public final class TmchDnlAction implements Runnable {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
private static final String DNL_CSV_PATH = "/dnl/dnl-latest.csv";
private static final String DNL_SIG_PATH = "/dnl/dnl-latest.sig";
@ -56,7 +56,8 @@ public final class TmchDnlAction implements Runnable {
}
ClaimsListShard claims = ClaimsListParser.parse(lines);
claims.save();
logger.infofmt("Inserted %,d claims into Datastore, created at %s",
logger.atInfo().log(
"Inserted %,d claims into Datastore, created at %s",
claims.size(), claims.getCreationTime());
}
}

View file

@ -16,7 +16,7 @@ package google.registry.tmch;
import static google.registry.request.Action.Method.POST;
import com.google.common.logging.FormattingLogger;
import com.google.common.flogger.FluentLogger;
import google.registry.keyring.api.KeyModule.Key;
import google.registry.model.smd.SignedMarkRevocationList;
import google.registry.request.Action;
@ -37,7 +37,7 @@ import org.bouncycastle.openpgp.PGPException;
)
public final class TmchSmdrlAction implements Runnable {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
private static final String SMDRL_CSV_PATH = "/smdrl/smdrl-latest.csv";
private static final String SMDRL_SIG_PATH = "/smdrl/smdrl-latest.sig";
@ -56,7 +56,7 @@ public final class TmchSmdrlAction implements Runnable {
}
SignedMarkRevocationList smdrl = SmdrlCsvParser.parse(lines);
smdrl.save();
logger.infofmt(
logger.atInfo().log(
"Inserted %,d smd revocations into Datastore, created at %s",
smdrl.size(), smdrl.getCreationTime());
}