Migrate to Flogger (yellow)

This is a 'yellow' Flogger migration CL. Yellow CLs should be mostly safe
but include changes that are notable for one reason or another. Manual
intervention may be required to address small issues.

The comments in this CL indicate cases where suggested code changes
should be double checked, or even modified. There may even be cases where
files outside this CL are affected by changes to things such as logger
visibility. However if a change does not have an associated comment then
it should be safe.

For more information, see []
Base CL: 197826149

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=198097990
This commit is contained in:
jianglai 2018-05-25 13:56:19 -07:00
parent 92190f8699
commit 4be4fb0082
21 changed files with 69 additions and 52 deletions

View file

@ -13,6 +13,8 @@ java_library(
deps = [
"//java/google/registry/keyring/api",
"//javatests/google/registry/testing",
"@com_google_flogger",
"@com_google_flogger_system_backend",
"@com_google_guava_testlib",
"@com_google_truth",
"@com_google_truth_extensions_truth_java8_extension",

View file

@ -21,6 +21,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import com.google.common.flogger.LoggerConfig;
import com.google.common.testing.TestLogHandler;
import java.io.IOException;
import java.util.logging.Level;
@ -80,12 +81,12 @@ public class ComparatorKeyringTest {
@Before
public void setUp() {
ComparatorKeyring.logger.getFormattingLogger().addHandler(testLogHandler);
LoggerConfig.getConfig(ComparatorKeyring.class).addHandler(testLogHandler);
}
@After
public void tearDown() {
ComparatorKeyring.logger.getFormattingLogger().removeHandler(testLogHandler);
LoggerConfig.getConfig(ComparatorKeyring.class).removeHandler(testLogHandler);
}
@Test

View file

@ -27,6 +27,8 @@ java_library(
"//third_party/objectify:objectify-v4_1",
"@com_braintreepayments_gateway_braintree_java",
"@com_google_appengine_api_1_0_sdk//:testonly",
"@com_google_flogger",
"@com_google_flogger_system_backend",
"@com_google_guava",
"@com_google_guava_testlib",
"@com_google_truth",

View file

@ -28,6 +28,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import com.google.appengine.api.users.User;
import com.google.common.flogger.LoggerConfig;
import com.google.common.testing.NullPointerTester;
import com.google.common.testing.TestLogHandler;
import google.registry.model.registrar.RegistrarContact;
@ -77,7 +78,7 @@ public class SessionUtilsTest {
@Before
public void before() throws Exception {
SessionUtils.logger.getFormattingLogger().addHandler(testLogHandler);
LoggerConfig.getConfig(SessionUtils.class).addHandler(testLogHandler);
sessionUtils = new SessionUtils();
sessionUtils.registryAdminClientId = ADMIN_CLIENT_ID;
persistResource(loadRegistrar(ADMIN_CLIENT_ID));
@ -86,7 +87,7 @@ public class SessionUtilsTest {
@After
public void after() throws Exception {
SessionUtils.logger.getFormattingLogger().removeHandler(testLogHandler);
LoggerConfig.getConfig(SessionUtils.class).removeHandler(testLogHandler);
}
/** User needs to be logged in before calling checkRegistrarConsoleLogin */

View file

@ -16,6 +16,8 @@ java_library(
"//javatests/google/registry/testing",
"@com_google_appengine_api_1_0_sdk",
"@com_google_code_findbugs_jsr305",
"@com_google_flogger",
"@com_google_flogger_system_backend",
"@com_google_guava",
"@com_google_guava_testlib",
"@com_google_re2j",

View file

@ -25,6 +25,7 @@ import com.google.appengine.api.log.LogService;
import com.google.appengine.api.log.RequestLogs;
import com.google.apphosting.api.ApiProxy;
import com.google.common.collect.ImmutableList;
import com.google.common.flogger.LoggerConfig;
import com.google.common.testing.TestLogHandler;
import google.registry.testing.AppEngineRule;
import java.util.logging.Level;
@ -69,12 +70,12 @@ public final class RequestStatusCheckerImplTest {
public AppEngineRule appEngineRule = AppEngineRule.builder().build();
@Before public void setUp() {
RequestStatusCheckerImpl.logger.getFormattingLogger().addHandler(logHandler);
LoggerConfig.getConfig(RequestStatusCheckerImpl.class).addHandler(logHandler);
RequestStatusCheckerImpl.logService = mock(LogService.class);
}
@After public void tearDown() {
RequestStatusCheckerImpl.logger.getFormattingLogger().removeHandler(logHandler);
LoggerConfig.getConfig(RequestStatusCheckerImpl.class).removeHandler(logHandler);
}
// If a logId is unrecognized, it could be that the log hasn't been uploaded yet - so we assume

View file

@ -22,6 +22,8 @@ java_library(
"@com_google_appengine_api_1_0_sdk",
"@com_google_appengine_testing",
"@com_google_dagger",
"@com_google_flogger",
"@com_google_flogger_system_backend",
"@com_google_guava",
"@com_google_guava_testlib",
"@com_google_truth",

View file

@ -19,6 +19,7 @@ import static google.registry.testing.DatastoreHelper.createTlds;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.testing.LogsSubject.assertAboutLogs;
import com.google.common.flogger.LoggerConfig;
import com.google.common.testing.TestLogHandler;
import google.registry.testing.AppEngineRule;
import google.registry.testing.FakeClock;
@ -41,7 +42,7 @@ public class WhoisReaderTest {
@Before
public void init() {
createTlds("tld", "xn--kgbechtv", "1.test");
WhoisReader.logger.getFormattingLogger().addHandler(testLogHandler);
LoggerConfig.getConfig(WhoisReader.class).addHandler(testLogHandler);
}
@SuppressWarnings({"TypeParameterUnusedInFormals", "unchecked"})