mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 16:07:15 +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_appengine_tools_appengine_gcs_client",
|
||||||
"@com_google_code_findbugs_jsr305",
|
"@com_google_code_findbugs_jsr305",
|
||||||
"@com_google_dagger",
|
"@com_google_dagger",
|
||||||
|
"@com_google_flogger",
|
||||||
|
"@com_google_flogger_system_backend",
|
||||||
"@com_google_guava",
|
"@com_google_guava",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
|
@ -32,6 +32,8 @@ java_library(
|
||||||
"@com_google_auto_value",
|
"@com_google_auto_value",
|
||||||
"@com_google_code_findbugs_jsr305",
|
"@com_google_code_findbugs_jsr305",
|
||||||
"@com_google_dagger",
|
"@com_google_dagger",
|
||||||
|
"@com_google_flogger",
|
||||||
|
"@com_google_flogger_system_backend",
|
||||||
"@com_google_guava",
|
"@com_google_guava",
|
||||||
"@com_google_re2j",
|
"@com_google_re2j",
|
||||||
"@javax_servlet_api",
|
"@javax_servlet_api",
|
||||||
|
|
|
@ -26,7 +26,7 @@ import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.ImmutableSetMultimap;
|
import com.google.common.collect.ImmutableSetMultimap;
|
||||||
import com.google.common.collect.Multimaps;
|
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.config.RegistryConfig.Config;
|
||||||
import google.registry.mapreduce.MapreduceRunner;
|
import google.registry.mapreduce.MapreduceRunner;
|
||||||
import google.registry.mapreduce.inputs.EppResourceInputs;
|
import google.registry.mapreduce.inputs.EppResourceInputs;
|
||||||
|
@ -194,7 +194,7 @@ public final class RdeStagingAction implements Runnable {
|
||||||
|
|
||||||
public static final String PATH = "/_dr/task/rdeStaging";
|
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 Clock clock;
|
||||||
@Inject PendingDepositChecker pendingDepositChecker;
|
@Inject PendingDepositChecker pendingDepositChecker;
|
||||||
|
@ -218,12 +218,14 @@ public final class RdeStagingAction implements Runnable {
|
||||||
manual ? getManualPendingDeposits() : getStandardPendingDeposits();
|
manual ? getManualPendingDeposits() : getStandardPendingDeposits();
|
||||||
if (pendings.isEmpty()) {
|
if (pendings.isEmpty()) {
|
||||||
String message = "Nothing needs to be deposited";
|
String message = "Nothing needs to be deposited";
|
||||||
logger.info(message);
|
logger.atInfo().log(message);
|
||||||
response.setStatus(SC_NO_CONTENT);
|
response.setStatus(SC_NO_CONTENT);
|
||||||
response.setPayload(message);
|
response.setPayload(message);
|
||||||
return;
|
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);
|
RdeStagingMapper mapper = new RdeStagingMapper(lenient ? LENIENT : STRICT, pendings);
|
||||||
|
|
||||||
response.sendJavaScriptRedirect(createJobPath(mrRunner
|
response.sendJavaScriptRedirect(createJobPath(mrRunner
|
||||||
|
@ -261,7 +263,8 @@ public final class RdeStagingAction implements Runnable {
|
||||||
pendingDepositChecker.getTldsAndWatermarksPendingDepositForRdeAndBrda(),
|
pendingDepositChecker.getTldsAndWatermarksPendingDepositForRdeAndBrda(),
|
||||||
pending -> {
|
pending -> {
|
||||||
if (clock.nowUtc().isBefore(pending.watermark().plus(transactionCooldown))) {
|
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;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -29,6 +29,8 @@ java_library(
|
||||||
"@com_google_appengine_tools_appengine_pipeline",
|
"@com_google_appengine_tools_appengine_pipeline",
|
||||||
"@com_google_code_findbugs_jsr305",
|
"@com_google_code_findbugs_jsr305",
|
||||||
"@com_google_dagger",
|
"@com_google_dagger",
|
||||||
|
"@com_google_flogger",
|
||||||
|
"@com_google_flogger_system_backend",
|
||||||
"@com_google_guava",
|
"@com_google_guava",
|
||||||
"@javax_servlet_api",
|
"@javax_servlet_api",
|
||||||
"@joda_time",
|
"@joda_time",
|
||||||
|
|
|
@ -14,11 +14,12 @@
|
||||||
|
|
||||||
package google.registry.tools.server;
|
package google.registry.tools.server;
|
||||||
|
|
||||||
|
import static com.google.common.flogger.LazyArgs.lazy;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
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.JsonResponse;
|
||||||
import google.registry.request.Parameter;
|
import google.registry.request.Parameter;
|
||||||
import java.util.logging.Level;
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,7 +27,7 @@ import javax.inject.Inject;
|
||||||
*/
|
*/
|
||||||
public abstract class CreateOrUpdatePremiumListAction implements Runnable {
|
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;
|
private static final int MAX_LOGGING_PREMIUM_LIST_LENGTH = 1000;
|
||||||
|
|
||||||
|
@ -42,23 +43,25 @@ public abstract class CreateOrUpdatePremiumListAction implements Runnable {
|
||||||
try {
|
try {
|
||||||
savePremiumList();
|
savePremiumList();
|
||||||
} catch (IllegalArgumentException e) {
|
} 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"));
|
response.setPayload(ImmutableMap.of("error", e.toString(), "status", "error"));
|
||||||
} catch (Exception e) {
|
} 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"));
|
response.setPayload(ImmutableMap.of("error", e.toString(), "status", "error"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Logs the premium list data at INFO, truncated if too long. */
|
/** Logs the premium list data at INFO, truncated if too long. */
|
||||||
void logInputData() {
|
void logInputData() {
|
||||||
if (logger.isLoggable(Level.INFO)) {
|
logger.atInfo().log(
|
||||||
logger.infofmt(
|
|
||||||
"Received the following input data: %s",
|
"Received the following input data: %s",
|
||||||
|
lazy(
|
||||||
|
() ->
|
||||||
(inputData.length() < MAX_LOGGING_PREMIUM_LIST_LENGTH)
|
(inputData.length() < MAX_LOGGING_PREMIUM_LIST_LENGTH)
|
||||||
? inputData
|
? inputData
|
||||||
: (inputData.substring(0, MAX_LOGGING_PREMIUM_LIST_LENGTH) + "<truncated>"));
|
: (inputData.substring(0, MAX_LOGGING_PREMIUM_LIST_LENGTH) + "<truncated>")));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Creates a new premium list or updates an existing one. */
|
/** 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.base.Splitter;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.common.flogger.FluentLogger;
|
||||||
import google.registry.model.registry.label.PremiumList;
|
import google.registry.model.registry.label.PremiumList;
|
||||||
import google.registry.request.Action;
|
import google.registry.request.Action;
|
||||||
import google.registry.request.Parameter;
|
import google.registry.request.Parameter;
|
||||||
|
@ -40,6 +41,8 @@ import javax.inject.Inject;
|
||||||
)
|
)
|
||||||
public class CreatePremiumListAction extends CreateOrUpdatePremiumListAction {
|
public class CreatePremiumListAction extends CreateOrUpdatePremiumListAction {
|
||||||
|
|
||||||
|
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||||
|
|
||||||
public static final String OVERRIDE_PARAM = "override";
|
public static final String OVERRIDE_PARAM = "override";
|
||||||
public static final String PATH = "/_dr/admin/createPremiumList";
|
public static final String PATH = "/_dr/admin/createPremiumList";
|
||||||
|
|
||||||
|
@ -54,7 +57,7 @@ public class CreatePremiumListAction extends CreateOrUpdatePremiumListAction {
|
||||||
assertTldExists(name);
|
assertTldExists(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.infofmt("Saving premium list for TLD %s", name);
|
logger.atInfo().log("Saving premium list for TLD %s", name);
|
||||||
logInputData();
|
logInputData();
|
||||||
List<String> inputDataPreProcessed =
|
List<String> inputDataPreProcessed =
|
||||||
Splitter.on('\n').omitEmptyStrings().splitToList(inputData);
|
Splitter.on('\n').omitEmptyStrings().splitToList(inputData);
|
||||||
|
@ -65,7 +68,7 @@ public class CreatePremiumListAction extends CreateOrUpdatePremiumListAction {
|
||||||
String.format(
|
String.format(
|
||||||
"Saved premium list %s with %d entries",
|
"Saved premium list %s with %d entries",
|
||||||
premiumList.getName(), inputDataPreProcessed.size());
|
premiumList.getName(), inputDataPreProcessed.size());
|
||||||
logger.info(message);
|
logger.atInfo().log(message);
|
||||||
response.setPayload(ImmutableMap.of("status", "success", "message", 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.base.Splitter;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.common.flogger.FluentLogger;
|
||||||
import google.registry.model.registry.label.PremiumList;
|
import google.registry.model.registry.label.PremiumList;
|
||||||
import google.registry.request.Action;
|
import google.registry.request.Action;
|
||||||
import google.registry.request.auth.Auth;
|
import google.registry.request.auth.Auth;
|
||||||
|
@ -38,6 +39,8 @@ import javax.inject.Inject;
|
||||||
)
|
)
|
||||||
public class UpdatePremiumListAction extends CreateOrUpdatePremiumListAction {
|
public class UpdatePremiumListAction extends CreateOrUpdatePremiumListAction {
|
||||||
|
|
||||||
|
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||||
|
|
||||||
public static final String PATH = "/_dr/admin/updatePremiumList";
|
public static final String PATH = "/_dr/admin/updatePremiumList";
|
||||||
|
|
||||||
@Inject UpdatePremiumListAction() {}
|
@Inject UpdatePremiumListAction() {}
|
||||||
|
@ -50,7 +53,7 @@ public class UpdatePremiumListAction extends CreateOrUpdatePremiumListAction {
|
||||||
"Could not update premium list %s because it doesn't exist.",
|
"Could not update premium list %s because it doesn't exist.",
|
||||||
name);
|
name);
|
||||||
|
|
||||||
logger.infofmt("Updating premium list for TLD %s", name);
|
logger.atInfo().log("Updating premium list for TLD %s", name);
|
||||||
logInputData();
|
logInputData();
|
||||||
List<String> inputDataPreProcessed =
|
List<String> inputDataPreProcessed =
|
||||||
Splitter.on('\n').omitEmptyStrings().splitToList(inputData);
|
Splitter.on('\n').omitEmptyStrings().splitToList(inputData);
|
||||||
|
@ -61,7 +64,7 @@ public class UpdatePremiumListAction extends CreateOrUpdatePremiumListAction {
|
||||||
String.format(
|
String.format(
|
||||||
"Updated premium list %s with %d entries.",
|
"Updated premium list %s with %d entries.",
|
||||||
newPremiumList.getName(), inputDataPreProcessed.size());
|
newPremiumList.getName(), inputDataPreProcessed.size());
|
||||||
logger.info(message);
|
logger.atInfo().log(message);
|
||||||
response.setPayload(ImmutableMap.of("status", "success", "message", message));
|
response.setPayload(ImmutableMap.of("status", "success", "message", message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,8 @@ java_library(
|
||||||
"@com_google_appengine_api_1_0_sdk//:testonly",
|
"@com_google_appengine_api_1_0_sdk//:testonly",
|
||||||
"@com_google_appengine_tools_appengine_gcs_client",
|
"@com_google_appengine_tools_appengine_gcs_client",
|
||||||
"@com_google_code_findbugs_jsr305",
|
"@com_google_code_findbugs_jsr305",
|
||||||
|
"@com_google_flogger",
|
||||||
|
"@com_google_flogger_system_backend",
|
||||||
"@com_google_guava",
|
"@com_google_guava",
|
||||||
"@com_google_guava_testlib",
|
"@com_google_guava_testlib",
|
||||||
"@com_google_truth",
|
"@com_google_truth",
|
||||||
|
|
|
@ -32,6 +32,7 @@ import com.google.appengine.tools.cloudstorage.GcsServiceFactory;
|
||||||
import com.google.appengine.tools.cloudstorage.ListItem;
|
import com.google.appengine.tools.cloudstorage.ListItem;
|
||||||
import com.google.appengine.tools.cloudstorage.ListResult;
|
import com.google.appengine.tools.cloudstorage.ListResult;
|
||||||
import com.google.common.collect.Iterators;
|
import com.google.common.collect.Iterators;
|
||||||
|
import com.google.common.flogger.LoggerConfig;
|
||||||
import com.google.common.testing.TestLogHandler;
|
import com.google.common.testing.TestLogHandler;
|
||||||
import google.registry.testing.AppEngineRule;
|
import google.registry.testing.AppEngineRule;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -42,7 +43,6 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.logging.LogRecord;
|
import java.util.logging.LogRecord;
|
||||||
import java.util.logging.Logger;
|
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
|
@ -79,7 +79,7 @@ public class GcsDiffFileListerTest {
|
||||||
.build(),
|
.build(),
|
||||||
ByteBuffer.wrap(new byte[]{1, 2, 3}));
|
ByteBuffer.wrap(new byte[]{1, 2, 3}));
|
||||||
}
|
}
|
||||||
Logger.getLogger(GcsDiffFileLister.class.getCanonicalName()).addHandler(logHandler);
|
LoggerConfig.getConfig(GcsDiffFileLister.class).addHandler(logHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Iterable<DateTime> extractTimesFromDiffFiles(List<GcsFileMetadata> diffFiles) {
|
private Iterable<DateTime> extractTimesFromDiffFiles(List<GcsFileMetadata> diffFiles) {
|
||||||
|
|
|
@ -35,6 +35,8 @@ java_library(
|
||||||
"@com_google_appengine_tools_appengine_gcs_client",
|
"@com_google_appengine_tools_appengine_gcs_client",
|
||||||
"@com_google_code_findbugs_jsr305",
|
"@com_google_code_findbugs_jsr305",
|
||||||
"@com_google_dagger",
|
"@com_google_dagger",
|
||||||
|
"@com_google_flogger",
|
||||||
|
"@com_google_flogger_system_backend",
|
||||||
"@com_google_guava",
|
"@com_google_guava",
|
||||||
"@com_google_http_client",
|
"@com_google_http_client",
|
||||||
"@com_google_re2j",
|
"@com_google_re2j",
|
||||||
|
|
|
@ -34,6 +34,7 @@ import com.google.api.services.bigquery.model.JobStatus;
|
||||||
import com.google.appengine.api.taskqueue.TaskOptions;
|
import com.google.appengine.api.taskqueue.TaskOptions;
|
||||||
import com.google.appengine.api.taskqueue.TaskOptions.Method;
|
import com.google.appengine.api.taskqueue.TaskOptions.Method;
|
||||||
import com.google.appengine.api.taskqueue.dev.QueueStateInfo.TaskStateInfo;
|
import com.google.appengine.api.taskqueue.dev.QueueStateInfo.TaskStateInfo;
|
||||||
|
import com.google.common.flogger.LoggerConfig;
|
||||||
import google.registry.export.BigqueryPollJobAction.BigqueryPollJobEnqueuer;
|
import google.registry.export.BigqueryPollJobAction.BigqueryPollJobEnqueuer;
|
||||||
import google.registry.request.HttpException.BadRequestException;
|
import google.registry.request.HttpException.BadRequestException;
|
||||||
import google.registry.request.HttpException.NotModifiedException;
|
import google.registry.request.HttpException.NotModifiedException;
|
||||||
|
@ -52,7 +53,6 @@ import java.io.ObjectInputStream;
|
||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.LogRecord;
|
import java.util.logging.LogRecord;
|
||||||
import java.util.logging.Logger;
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -90,7 +90,7 @@ public class BigqueryPollJobActionTest {
|
||||||
action.projectId = PROJECT_ID;
|
action.projectId = PROJECT_ID;
|
||||||
action.jobId = JOB_ID;
|
action.jobId = JOB_ID;
|
||||||
action.chainedQueueName = () -> CHAINED_QUEUE_NAME;
|
action.chainedQueueName = () -> CHAINED_QUEUE_NAME;
|
||||||
Logger.getLogger(BigqueryPollJobAction.class.getName()).addHandler(logHandler);
|
LoggerConfig.getConfig(BigqueryPollJobAction.class).addHandler(logHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static TaskMatcher newPollJobTaskMatcher(String method) throws Exception {
|
private static TaskMatcher newPollJobTaskMatcher(String method) throws Exception {
|
||||||
|
|
|
@ -43,6 +43,8 @@ java_library(
|
||||||
"@com_google_appengine_testing",
|
"@com_google_appengine_testing",
|
||||||
"@com_google_code_findbugs_jsr305",
|
"@com_google_code_findbugs_jsr305",
|
||||||
"@com_google_dagger",
|
"@com_google_dagger",
|
||||||
|
"@com_google_flogger",
|
||||||
|
"@com_google_flogger_system_backend",
|
||||||
"@com_google_guava",
|
"@com_google_guava",
|
||||||
"@com_google_guava_testlib",
|
"@com_google_guava_testlib",
|
||||||
"@com_google_monitoring_client_metrics",
|
"@com_google_monitoring_client_metrics",
|
||||||
|
|
|
@ -20,6 +20,7 @@ import static google.registry.testing.JUnitBackports.assertThrows;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.common.flogger.LoggerConfig;
|
||||||
import com.google.common.testing.TestLogHandler;
|
import com.google.common.testing.TestLogHandler;
|
||||||
import google.registry.flows.EppException.UnimplementedExtensionException;
|
import google.registry.flows.EppException.UnimplementedExtensionException;
|
||||||
import google.registry.flows.ExtensionManager.UndeclaredServiceExtensionException;
|
import google.registry.flows.ExtensionManager.UndeclaredServiceExtensionException;
|
||||||
|
@ -37,7 +38,6 @@ import google.registry.model.eppinput.EppInput.CommandExtension;
|
||||||
import google.registry.testing.AppEngineRule;
|
import google.registry.testing.AppEngineRule;
|
||||||
import google.registry.util.TypeUtils;
|
import google.registry.util.TypeUtils;
|
||||||
import java.util.logging.LogRecord;
|
import java.util.logging.LogRecord;
|
||||||
import java.util.logging.Logger;
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
@ -70,7 +70,7 @@ public class ExtensionManagerTest {
|
||||||
@Test
|
@Test
|
||||||
public void testUndeclaredExtensionsLogged() throws Exception {
|
public void testUndeclaredExtensionsLogged() throws Exception {
|
||||||
TestLogHandler handler = new TestLogHandler();
|
TestLogHandler handler = new TestLogHandler();
|
||||||
Logger.getLogger(ExtensionManager.class.getCanonicalName()).addHandler(handler);
|
LoggerConfig.getConfig(ExtensionManager.class).addHandler(handler);
|
||||||
ExtensionManager manager =
|
ExtensionManager manager =
|
||||||
new TestInstanceBuilder()
|
new TestInstanceBuilder()
|
||||||
.setEppRequestSource(EppRequestSource.TOOL)
|
.setEppRequestSource(EppRequestSource.TOOL)
|
||||||
|
|
|
@ -23,6 +23,7 @@ import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.flogger.LoggerConfig;
|
||||||
import com.google.common.testing.TestLogHandler;
|
import com.google.common.testing.TestLogHandler;
|
||||||
import google.registry.flows.annotations.ReportingSpec;
|
import google.registry.flows.annotations.ReportingSpec;
|
||||||
import google.registry.model.eppcommon.Trid;
|
import google.registry.model.eppcommon.Trid;
|
||||||
|
@ -33,7 +34,6 @@ import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
|
||||||
import google.registry.testing.ShardableTestCase;
|
import google.registry.testing.ShardableTestCase;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.logging.Logger;
|
|
||||||
import org.json.simple.JSONValue;
|
import org.json.simple.JSONValue;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -64,7 +64,7 @@ public class FlowReporterTest extends ShardableTestCase {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void before() {
|
public void before() {
|
||||||
Logger.getLogger(FlowReporter.class.getCanonicalName()).addHandler(handler);
|
LoggerConfig.getConfig(FlowReporter.class).addHandler(handler);
|
||||||
flowReporter.trid = Trid.create("client-123", "server-456");
|
flowReporter.trid = Trid.create("client-123", "server-456");
|
||||||
flowReporter.clientId = "TheRegistrar";
|
flowReporter.clientId = "TheRegistrar";
|
||||||
flowReporter.inputXmlBytes = "<xml/>".getBytes(UTF_8);
|
flowReporter.inputXmlBytes = "<xml/>".getBytes(UTF_8);
|
||||||
|
|
|
@ -27,6 +27,7 @@ import com.google.appengine.api.users.User;
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
import com.google.common.base.Splitter;
|
import com.google.common.base.Splitter;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.common.flogger.LoggerConfig;
|
||||||
import com.google.common.testing.TestLogHandler;
|
import com.google.common.testing.TestLogHandler;
|
||||||
import google.registry.model.eppcommon.Trid;
|
import google.registry.model.eppcommon.Trid;
|
||||||
import google.registry.model.eppoutput.EppOutput.ResponseOrGreeting;
|
import google.registry.model.eppoutput.EppOutput.ResponseOrGreeting;
|
||||||
|
@ -38,7 +39,6 @@ import google.registry.testing.FakeHttpSession;
|
||||||
import google.registry.testing.ShardableTestCase;
|
import google.registry.testing.ShardableTestCase;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.logging.Logger;
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -68,7 +68,7 @@ public class FlowRunnerTest extends ShardableTestCase {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void before() {
|
public void before() {
|
||||||
Logger.getLogger(FlowRunner.class.getCanonicalName()).addHandler(handler);
|
LoggerConfig.getConfig(FlowRunner.class).addHandler(handler);
|
||||||
flowRunner.clientId = "TheRegistrar";
|
flowRunner.clientId = "TheRegistrar";
|
||||||
flowRunner.credentials = new PasswordOnlyTransportCredentials();
|
flowRunner.credentials = new PasswordOnlyTransportCredentials();
|
||||||
flowRunner.eppRequestSource = EppRequestSource.UNIT_TEST;
|
flowRunner.eppRequestSource = EppRequestSource.UNIT_TEST;
|
||||||
|
|
|
@ -27,6 +27,7 @@ import static google.registry.testing.TaskQueueHelper.assertTasksEnqueued;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.Streams;
|
import com.google.common.collect.Streams;
|
||||||
|
import com.google.common.flogger.LoggerConfig;
|
||||||
import com.google.common.testing.TestLogHandler;
|
import com.google.common.testing.TestLogHandler;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import google.registry.flows.FlowUtils.NotLoggedInException;
|
import google.registry.flows.FlowUtils.NotLoggedInException;
|
||||||
|
@ -45,7 +46,6 @@ import google.registry.testing.TaskQueueHelper.TaskMatcher;
|
||||||
import google.registry.util.TypeUtils.TypeInstantiator;
|
import google.registry.util.TypeUtils.TypeInstantiator;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.joda.time.Duration;
|
import org.joda.time.Duration;
|
||||||
import org.json.simple.JSONValue;
|
import org.json.simple.JSONValue;
|
||||||
|
@ -68,7 +68,7 @@ public abstract class ResourceFlowTestCase<F extends Flow, R extends EppResource
|
||||||
// Attach TestLogHandler to the root logger so it has access to all log messages.
|
// Attach TestLogHandler to the root logger so it has access to all log messages.
|
||||||
// Note that in theory for assertIcannReportingActivityFieldLogged() below it would suffice to
|
// Note that in theory for assertIcannReportingActivityFieldLogged() below it would suffice to
|
||||||
// attach it only to the FlowRunner logger, but for some reason this doesn't work for all flows.
|
// attach it only to the FlowRunner logger, but for some reason this doesn't work for all flows.
|
||||||
Logger.getLogger("").addHandler(logHandler);
|
LoggerConfig.getConfig("").addHandler(logHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected R reloadResourceByForeignKey(DateTime now) throws Exception {
|
protected R reloadResourceByForeignKey(DateTime now) throws Exception {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue