mirror of
https://github.com/google/nomulus.git
synced 2025-05-15 08:57:12 +02:00
Migrate to flogger (red)
This is a 'red' Flogger migration CL. Red CLs contain changes which are likely not to work without manual intervention. Note that it may not even be possible to directly migrate the logger usage in this CL to the Flogger API and some additional refactoring may be required. If this is the case, please note that it should be safe to submit any outstanding 'green' and 'yellow' CLs prior to tackling this. If you feel that your use case is not covered by the existing Flogger API please raise a feature request at []and revert this CL. For more information, see [] Base CL: 197826149 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=198463651
This commit is contained in:
parent
65ac28fae5
commit
1f1705aaa6
16 changed files with 57 additions and 33 deletions
|
@ -13,6 +13,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",
|
||||
],
|
||||
)
|
||||
|
|
|
@ -32,6 +32,8 @@ java_library(
|
|||
"@com_google_auto_value",
|
||||
"@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",
|
||||
|
|
|
@ -26,7 +26,7 @@ import com.google.common.collect.ImmutableList;
|
|||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSetMultimap;
|
||||
import com.google.common.collect.Multimaps;
|
||||
import com.google.common.logging.FormattingLogger;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import google.registry.config.RegistryConfig.Config;
|
||||
import google.registry.mapreduce.MapreduceRunner;
|
||||
import google.registry.mapreduce.inputs.EppResourceInputs;
|
||||
|
@ -194,7 +194,7 @@ public final class RdeStagingAction implements Runnable {
|
|||
|
||||
public static final String PATH = "/_dr/task/rdeStaging";
|
||||
|
||||
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
@Inject Clock clock;
|
||||
@Inject PendingDepositChecker pendingDepositChecker;
|
||||
|
@ -218,12 +218,14 @@ public final class RdeStagingAction implements Runnable {
|
|||
manual ? getManualPendingDeposits() : getStandardPendingDeposits();
|
||||
if (pendings.isEmpty()) {
|
||||
String message = "Nothing needs to be deposited";
|
||||
logger.info(message);
|
||||
logger.atInfo().log(message);
|
||||
response.setStatus(SC_NO_CONTENT);
|
||||
response.setPayload(message);
|
||||
return;
|
||||
}
|
||||
pendings.values().stream().map(Object::toString).forEach(logger::info);
|
||||
for (PendingDeposit pending : pendings.values()) {
|
||||
logger.atInfo().log("Pending deposit: %s", pending);
|
||||
}
|
||||
RdeStagingMapper mapper = new RdeStagingMapper(lenient ? LENIENT : STRICT, pendings);
|
||||
|
||||
response.sendJavaScriptRedirect(createJobPath(mrRunner
|
||||
|
@ -261,7 +263,8 @@ public final class RdeStagingAction implements Runnable {
|
|||
pendingDepositChecker.getTldsAndWatermarksPendingDepositForRdeAndBrda(),
|
||||
pending -> {
|
||||
if (clock.nowUtc().isBefore(pending.watermark().plus(transactionCooldown))) {
|
||||
logger.infofmt("Ignoring within %s cooldown: %s", transactionCooldown, pending);
|
||||
logger.atInfo().log(
|
||||
"Ignoring within %s cooldown: %s", transactionCooldown, pending);
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
|
|
|
@ -29,6 +29,8 @@ java_library(
|
|||
"@com_google_appengine_tools_appengine_pipeline",
|
||||
"@com_google_code_findbugs_jsr305",
|
||||
"@com_google_dagger",
|
||||
"@com_google_flogger",
|
||||
"@com_google_flogger_system_backend",
|
||||
"@com_google_guava",
|
||||
"@javax_servlet_api",
|
||||
"@joda_time",
|
||||
|
|
|
@ -14,11 +14,12 @@
|
|||
|
||||
package google.registry.tools.server;
|
||||
|
||||
import static com.google.common.flogger.LazyArgs.lazy;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.logging.FormattingLogger;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import google.registry.request.JsonResponse;
|
||||
import google.registry.request.Parameter;
|
||||
import java.util.logging.Level;
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
|
@ -26,7 +27,7 @@ import javax.inject.Inject;
|
|||
*/
|
||||
public abstract class CreateOrUpdatePremiumListAction implements Runnable {
|
||||
|
||||
protected static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private static final int MAX_LOGGING_PREMIUM_LIST_LENGTH = 1000;
|
||||
|
||||
|
@ -42,23 +43,25 @@ public abstract class CreateOrUpdatePremiumListAction implements Runnable {
|
|||
try {
|
||||
savePremiumList();
|
||||
} catch (IllegalArgumentException e) {
|
||||
logger.info(e, "Usage error in attempting to save premium list from nomulus tool command");
|
||||
logger.atInfo().withCause(e).log(
|
||||
"Usage error in attempting to save premium list from nomulus tool command");
|
||||
response.setPayload(ImmutableMap.of("error", e.toString(), "status", "error"));
|
||||
} catch (Exception e) {
|
||||
logger.severe(e, "Unexpected error saving premium list from nomulus tool command");
|
||||
logger.atSevere().withCause(e).log(
|
||||
"Unexpected error saving premium list from nomulus tool command");
|
||||
response.setPayload(ImmutableMap.of("error", e.toString(), "status", "error"));
|
||||
}
|
||||
}
|
||||
|
||||
/** Logs the premium list data at INFO, truncated if too long. */
|
||||
void logInputData() {
|
||||
if (logger.isLoggable(Level.INFO)) {
|
||||
logger.infofmt(
|
||||
"Received the following input data: %s",
|
||||
(inputData.length() < MAX_LOGGING_PREMIUM_LIST_LENGTH)
|
||||
? inputData
|
||||
: (inputData.substring(0, MAX_LOGGING_PREMIUM_LIST_LENGTH) + "<truncated>"));
|
||||
}
|
||||
logger.atInfo().log(
|
||||
"Received the following input data: %s",
|
||||
lazy(
|
||||
() ->
|
||||
(inputData.length() < MAX_LOGGING_PREMIUM_LIST_LENGTH)
|
||||
? inputData
|
||||
: (inputData.substring(0, MAX_LOGGING_PREMIUM_LIST_LENGTH) + "<truncated>")));
|
||||
}
|
||||
|
||||
/** Creates a new premium list or updates an existing one. */
|
||||
|
|
|
@ -22,6 +22,7 @@ import static google.registry.request.Action.Method.POST;
|
|||
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import google.registry.model.registry.label.PremiumList;
|
||||
import google.registry.request.Action;
|
||||
import google.registry.request.Parameter;
|
||||
|
@ -40,6 +41,8 @@ import javax.inject.Inject;
|
|||
)
|
||||
public class CreatePremiumListAction extends CreateOrUpdatePremiumListAction {
|
||||
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
public static final String OVERRIDE_PARAM = "override";
|
||||
public static final String PATH = "/_dr/admin/createPremiumList";
|
||||
|
||||
|
@ -54,7 +57,7 @@ public class CreatePremiumListAction extends CreateOrUpdatePremiumListAction {
|
|||
assertTldExists(name);
|
||||
}
|
||||
|
||||
logger.infofmt("Saving premium list for TLD %s", name);
|
||||
logger.atInfo().log("Saving premium list for TLD %s", name);
|
||||
logInputData();
|
||||
List<String> inputDataPreProcessed =
|
||||
Splitter.on('\n').omitEmptyStrings().splitToList(inputData);
|
||||
|
@ -65,7 +68,7 @@ public class CreatePremiumListAction extends CreateOrUpdatePremiumListAction {
|
|||
String.format(
|
||||
"Saved premium list %s with %d entries",
|
||||
premiumList.getName(), inputDataPreProcessed.size());
|
||||
logger.info(message);
|
||||
logger.atInfo().log(message);
|
||||
response.setPayload(ImmutableMap.of("status", "success", "message", message));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import static google.registry.request.Action.Method.POST;
|
|||
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import google.registry.model.registry.label.PremiumList;
|
||||
import google.registry.request.Action;
|
||||
import google.registry.request.auth.Auth;
|
||||
|
@ -38,6 +39,8 @@ import javax.inject.Inject;
|
|||
)
|
||||
public class UpdatePremiumListAction extends CreateOrUpdatePremiumListAction {
|
||||
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
public static final String PATH = "/_dr/admin/updatePremiumList";
|
||||
|
||||
@Inject UpdatePremiumListAction() {}
|
||||
|
@ -50,7 +53,7 @@ public class UpdatePremiumListAction extends CreateOrUpdatePremiumListAction {
|
|||
"Could not update premium list %s because it doesn't exist.",
|
||||
name);
|
||||
|
||||
logger.infofmt("Updating premium list for TLD %s", name);
|
||||
logger.atInfo().log("Updating premium list for TLD %s", name);
|
||||
logInputData();
|
||||
List<String> inputDataPreProcessed =
|
||||
Splitter.on('\n').omitEmptyStrings().splitToList(inputData);
|
||||
|
@ -61,7 +64,7 @@ public class UpdatePremiumListAction extends CreateOrUpdatePremiumListAction {
|
|||
String.format(
|
||||
"Updated premium list %s with %d entries.",
|
||||
newPremiumList.getName(), inputDataPreProcessed.size());
|
||||
logger.info(message);
|
||||
logger.atInfo().log(message);
|
||||
response.setPayload(ImmutableMap.of("status", "success", "message", message));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue