Merge branch 'stable-3.2'
* stable-3.2: LoggingContext: Avoid unboxing of Boolean to primitive boolean Initialize Flogger backend in TestLoggingActivator#configureLogging TestLoggingActivator: Add a private default constructor FloggerInitializer: Add a private default constructor Fix minor spelling mistake in trace log messages Use dedicated database connection for every schema migration ConfigSuite: Externalize flogger initialization in its own class Update jetty to 9.4.27.v20200227 Change-Id: I39b04559ecf2e79c27ef7f769ea641f5d607dd29
This commit is contained in:
		@@ -24,7 +24,6 @@ import com.google.common.base.MoreObjects;
 | 
			
		||||
import com.google.common.collect.ImmutableMap;
 | 
			
		||||
import com.google.common.collect.Iterables;
 | 
			
		||||
import com.google.common.collect.Lists;
 | 
			
		||||
import com.google.gerrit.server.logging.LoggingContext;
 | 
			
		||||
import java.lang.annotation.Annotation;
 | 
			
		||||
import java.lang.annotation.Retention;
 | 
			
		||||
import java.lang.annotation.Target;
 | 
			
		||||
@@ -107,16 +106,6 @@ import org.junit.runners.model.InitializationError;
 | 
			
		||||
 * field annotated with {@code @ConfigSuite.Name}.
 | 
			
		||||
 */
 | 
			
		||||
public class ConfigSuite extends Suite {
 | 
			
		||||
  private static final String FLOGGER_BACKEND_PROPERTY = "flogger.backend_factory";
 | 
			
		||||
  private static final String FLOGGER_LOGGING_CONTEXT = "flogger.logging_context";
 | 
			
		||||
 | 
			
		||||
  static {
 | 
			
		||||
    System.setProperty(
 | 
			
		||||
        FLOGGER_BACKEND_PROPERTY,
 | 
			
		||||
        "com.google.common.flogger.backend.log4j.Log4jBackendFactory#getInstance");
 | 
			
		||||
    System.setProperty(FLOGGER_LOGGING_CONTEXT, LoggingContext.class.getName() + "#getInstance");
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public static final String DEFAULT = "default";
 | 
			
		||||
 | 
			
		||||
  @Target({METHOD})
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										31
									
								
								java/com/google/gerrit/testing/FloggerInitializer.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								java/com/google/gerrit/testing/FloggerInitializer.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,31 @@
 | 
			
		||||
// Copyright (C) 2020 The Android Open Source Project
 | 
			
		||||
//
 | 
			
		||||
// Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
// you may not use this file except in compliance with the License.
 | 
			
		||||
// You may obtain a copy of the License at
 | 
			
		||||
//
 | 
			
		||||
// http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
//
 | 
			
		||||
// Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
// distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
// See the License for the specific language governing permissions and
 | 
			
		||||
// limitations under the License.
 | 
			
		||||
 | 
			
		||||
package com.google.gerrit.testing;
 | 
			
		||||
 | 
			
		||||
import com.google.gerrit.server.logging.LoggingContext;
 | 
			
		||||
 | 
			
		||||
public class FloggerInitializer {
 | 
			
		||||
  private static final String FLOGGER_BACKEND_PROPERTY = "flogger.backend_factory";
 | 
			
		||||
  private static final String FLOGGER_LOGGING_CONTEXT = "flogger.logging_context";
 | 
			
		||||
 | 
			
		||||
  private FloggerInitializer() {}
 | 
			
		||||
 | 
			
		||||
  public static void initBackend() {
 | 
			
		||||
    System.setProperty(
 | 
			
		||||
        FLOGGER_BACKEND_PROPERTY,
 | 
			
		||||
        "com.google.common.flogger.backend.log4j.Log4jBackendFactory#getInstance");
 | 
			
		||||
    System.setProperty(FLOGGER_LOGGING_CONTEXT, LoggingContext.class.getName() + "#getInstance");
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -83,6 +83,7 @@ public class TestLoggingActivator {
 | 
			
		||||
 | 
			
		||||
  public static void configureLogging() {
 | 
			
		||||
    LogManager.resetConfiguration();
 | 
			
		||||
    FloggerInitializer.initBackend();
 | 
			
		||||
 | 
			
		||||
    PatternLayout layout = new PatternLayout();
 | 
			
		||||
    layout.setConversionPattern("%-5p %c %x: %m%n");
 | 
			
		||||
@@ -99,4 +100,6 @@ public class TestLoggingActivator {
 | 
			
		||||
 | 
			
		||||
    LOG_LEVELS.entrySet().stream().forEach(e -> getLogger(e.getKey()).setLevel(e.getValue()));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private TestLoggingActivator() {}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user