mirror of
https://github.com/google/nomulus.git
synced 2025-07-20 09:46:03 +02:00
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:
parent
0d2fb3a8f0
commit
70b13596e4
178 changed files with 984 additions and 988 deletions
|
@ -9,7 +9,6 @@ java_library(
|
|||
srcs = glob(["*.java"]),
|
||||
resources = glob(["sql/*"]),
|
||||
deps = [
|
||||
"//java/com/google/common/logging:formatting_logger",
|
||||
"//java/google/registry/bigquery",
|
||||
"//java/google/registry/config",
|
||||
"//java/google/registry/gcs",
|
||||
|
@ -26,6 +25,8 @@ java_library(
|
|||
"@com_google_appengine_tools_appengine_gcs_client",
|
||||
"@com_google_code_findbugs_jsr305",
|
||||
"@com_google_dagger",
|
||||
"@com_google_flogger",
|
||||
"@com_google_flogger_system_backend",
|
||||
"@com_google_guava",
|
||||
"@com_google_http_client",
|
||||
"@com_google_http_client_jackson2",
|
||||
|
|
|
@ -27,8 +27,8 @@ import com.google.api.client.http.HttpResponse;
|
|||
import com.google.api.client.http.HttpTransport;
|
||||
import com.google.common.base.Ascii;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.google.common.logging.FormattingLogger;
|
||||
import google.registry.config.RegistryConfig.Config;
|
||||
import google.registry.keyring.api.KeyModule.Key;
|
||||
import google.registry.reporting.icann.IcannReportingModule.ReportType;
|
||||
|
@ -57,7 +57,7 @@ import org.joda.time.format.DateTimeFormat;
|
|||
*/
|
||||
public class IcannHttpReporter {
|
||||
|
||||
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
@Inject HttpTransport httpTransport;
|
||||
@Inject @Key("icannReportingPassword") String password;
|
||||
|
@ -81,9 +81,8 @@ public class IcannHttpReporter {
|
|||
request.setFollowRedirects(false);
|
||||
|
||||
HttpResponse response = null;
|
||||
logger.infofmt(
|
||||
"Sending report to %s with content length %s",
|
||||
uploadUrl.toString(), request.getContent().getLength());
|
||||
logger.atInfo().log(
|
||||
"Sending report to %s with content length %d", uploadUrl, request.getContent().getLength());
|
||||
boolean success = true;
|
||||
try {
|
||||
response = request.execute();
|
||||
|
@ -93,25 +92,22 @@ public class IcannHttpReporter {
|
|||
} finally {
|
||||
response.getContent().close();
|
||||
}
|
||||
logger.infofmt(
|
||||
"Received response code %s with content %s",
|
||||
logger.atInfo().log(
|
||||
"Received response code %d with content %s",
|
||||
response.getStatusCode(), new String(content, UTF_8));
|
||||
XjcIirdeaResult result = parseResult(content);
|
||||
if (result.getCode().getValue() != 1000) {
|
||||
success = false;
|
||||
logger.warningfmt(
|
||||
logger.atWarning().log(
|
||||
"PUT rejected, status code %s:\n%s\n%s",
|
||||
result.getCode(),
|
||||
result.getMsg(),
|
||||
result.getDescription());
|
||||
result.getCode(), result.getMsg(), result.getDescription());
|
||||
}
|
||||
} finally {
|
||||
if (response != null) {
|
||||
response.disconnect();
|
||||
} else {
|
||||
success = false;
|
||||
logger.warningfmt(
|
||||
"Received null response from ICANN server at %s", uploadUrl.toString());
|
||||
logger.atWarning().log("Received null response from ICANN server at %s", uploadUrl);
|
||||
}
|
||||
}
|
||||
return success;
|
||||
|
|
|
@ -30,7 +30,7 @@ import com.google.common.collect.ImmutableMap;
|
|||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableTable;
|
||||
import com.google.common.collect.ListMultimap;
|
||||
import com.google.common.logging.FormattingLogger;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import google.registry.bigquery.BigqueryConnection;
|
||||
import google.registry.bigquery.BigqueryUtils.TableType;
|
||||
import google.registry.config.RegistryConfig.Config;
|
||||
|
@ -58,7 +58,7 @@ import org.joda.time.format.DateTimeFormat;
|
|||
*/
|
||||
public class IcannReportingStager {
|
||||
|
||||
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
@Inject @Config("icannReportingBucket") String reportingBucket;
|
||||
|
||||
|
@ -105,7 +105,7 @@ public class IcannReportingStager {
|
|||
private void createIntermediaryTableView(String queryName, String query, ReportType reportType)
|
||||
throws ExecutionException, InterruptedException {
|
||||
// Later views depend on the results of earlier ones, so query everything synchronously
|
||||
logger.infofmt("Generating intermediary view %s", queryName);
|
||||
logger.atInfo().log("Generating intermediary view %s", queryName);
|
||||
bigquery.query(
|
||||
query,
|
||||
bigquery.buildDestinationTable(queryName)
|
||||
|
@ -247,10 +247,7 @@ public class IcannReportingStager {
|
|||
String reportBucketname = String.format("%s/%s", reportingBucket, subdir);
|
||||
final GcsFilename gcsFilename = new GcsFilename(reportBucketname, reportFilename);
|
||||
gcsUtils.createFromBytes(gcsFilename, reportBytes);
|
||||
logger.infofmt(
|
||||
"Wrote %d bytes to file location %s",
|
||||
reportBytes.length,
|
||||
gcsFilename.toString());
|
||||
logger.atInfo().log("Wrote %d bytes to file location %s", reportBytes.length, gcsFilename);
|
||||
return reportFilename;
|
||||
}
|
||||
|
||||
|
@ -261,7 +258,6 @@ public class IcannReportingStager {
|
|||
StringBuilder manifestString = new StringBuilder();
|
||||
filenames.forEach((filename) -> manifestString.append(filename).append("\n"));
|
||||
gcsUtils.createFromBytes(gcsFilename, manifestString.toString().getBytes(UTF_8));
|
||||
logger.infofmt(
|
||||
"Wrote %d filenames to manifest at %s", filenames.size(), gcsFilename.toString());
|
||||
logger.atInfo().log("Wrote %d filenames to manifest at %s", filenames.size(), gcsFilename);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import com.google.appengine.api.taskqueue.TaskOptions;
|
|||
import com.google.appengine.api.taskqueue.TaskOptions.Method;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.logging.FormattingLogger;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.common.net.MediaType;
|
||||
import google.registry.bigquery.BigqueryJobFailureException;
|
||||
import google.registry.reporting.icann.IcannReportingModule.ReportType;
|
||||
|
@ -60,7 +60,7 @@ public final class IcannReportingStagingAction implements Runnable {
|
|||
|
||||
static final String PATH = "/_dr/task/icannReportingStaging";
|
||||
|
||||
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
private static final String CRON_QUEUE = "retryable-cron-tasks";
|
||||
|
||||
@Inject YearMonth yearMonth;
|
||||
|
@ -84,7 +84,7 @@ public final class IcannReportingStagingAction implements Runnable {
|
|||
ImmutableList<String> manifestedFiles = manifestedFilesBuilder.build();
|
||||
stager.createAndUploadManifest(manifestedFiles);
|
||||
|
||||
logger.infofmt("Completed staging %d report files.", manifestedFiles.size());
|
||||
logger.atInfo().log("Completed staging %d report files.", manifestedFiles.size());
|
||||
emailUtils.emailResults(
|
||||
"ICANN Monthly report staging summary [SUCCESS]",
|
||||
String.format(
|
||||
|
@ -95,7 +95,7 @@ public final class IcannReportingStagingAction implements Runnable {
|
|||
response.setContentType(MediaType.PLAIN_TEXT_UTF_8);
|
||||
response.setPayload("Completed staging action.");
|
||||
|
||||
logger.infofmt("Enqueueing report upload :");
|
||||
logger.atInfo().log("Enqueueing report upload :");
|
||||
TaskOptions uploadTask =
|
||||
TaskOptions.Builder.withUrl(IcannReportingUploadAction.PATH)
|
||||
.method(Method.POST)
|
||||
|
@ -111,14 +111,13 @@ public final class IcannReportingStagingAction implements Runnable {
|
|||
String.format(
|
||||
"Staging failed due to %s, check logs for more details.",
|
||||
getRootCause(e).toString()));
|
||||
logger.severe(e, "Staging action failed.");
|
||||
response.setStatus(SC_INTERNAL_SERVER_ERROR);
|
||||
response.setContentType(MediaType.PLAIN_TEXT_UTF_8);
|
||||
response.setPayload(
|
||||
String.format(
|
||||
"Staging failed due to %s",
|
||||
getRootCause(e).toString()));
|
||||
throw e;
|
||||
throw new RuntimeException("Staging action failed.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,8 +25,8 @@ import com.google.appengine.tools.cloudstorage.GcsFilename;
|
|||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.google.common.logging.FormattingLogger;
|
||||
import google.registry.config.RegistryConfig.Config;
|
||||
import google.registry.gcs.GcsUtils;
|
||||
import google.registry.reporting.icann.IcannReportingModule.ReportingSubdir;
|
||||
|
@ -57,7 +57,7 @@ public final class IcannReportingUploadAction implements Runnable {
|
|||
|
||||
static final String PATH = "/_dr/task/icannReportingUpload";
|
||||
|
||||
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
@Inject
|
||||
@Config("icannReportingBucket")
|
||||
|
@ -82,7 +82,8 @@ public final class IcannReportingUploadAction implements Runnable {
|
|||
ImmutableMap.Builder<String, Boolean> reportSummaryBuilder = new ImmutableMap.Builder<>();
|
||||
// Report on all manifested files
|
||||
for (String reportFilename : manifestedFiles) {
|
||||
logger.infofmt("Reading ICANN report %s from bucket %s", reportFilename, reportBucketname);
|
||||
logger.atInfo().log(
|
||||
"Reading ICANN report %s from bucket %s", reportFilename, reportBucketname);
|
||||
final GcsFilename gcsFilename = new GcsFilename(reportBucketname, reportFilename);
|
||||
verifyFileExists(gcsFilename);
|
||||
boolean success = false;
|
||||
|
@ -95,7 +96,7 @@ public final class IcannReportingUploadAction implements Runnable {
|
|||
},
|
||||
IOException.class);
|
||||
} catch (RuntimeException e) {
|
||||
logger.warningfmt(e, "Upload to %s failed.", gcsFilename.toString());
|
||||
logger.atWarning().withCause(e).log("Upload to %s failed.", gcsFilename);
|
||||
}
|
||||
reportSummaryBuilder.put(reportFilename, success);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
package google.registry.reporting.icann;
|
||||
|
||||
import com.google.common.logging.FormattingLogger;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import google.registry.config.RegistryConfig.Config;
|
||||
import google.registry.util.SendEmailService;
|
||||
import javax.inject.Inject;
|
||||
|
@ -30,19 +30,19 @@ public class ReportingEmailUtils {
|
|||
@Inject SendEmailService emailService;
|
||||
@Inject ReportingEmailUtils() {}
|
||||
|
||||
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
void emailResults(String subject, String body) {
|
||||
try {
|
||||
Message msg = emailService.createMessage();
|
||||
logger.infofmt("Emailing %s", recipient);
|
||||
logger.atInfo().log("Emailing %s", recipient);
|
||||
msg.setFrom(new InternetAddress(sender));
|
||||
msg.addRecipient(RecipientType.TO, new InternetAddress(recipient));
|
||||
msg.setSubject(subject);
|
||||
msg.setText(body);
|
||||
emailService.sendMessage(msg);
|
||||
} catch (Exception e) {
|
||||
logger.warning(e, "E-mail service failed.");
|
||||
logger.atWarning().withCause(e).log("E-mail service failed.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue