Merge branch 'stable-3.1'
* stable-3.1:
Update git submodules
Update download-commands plugin to latest master revision
Bazel: Bump java docs api to 11
Set Elastic/Lucene test deps log to WARN log level
Open relative commentlinks in same tab
VersionedMetaData: Emit debug log after update has been committed
VersionedMetaData: Trim message sent to log
Update git submodules
ChangeIdHandler: Make assumption on number of query results explicit
ChangeIdHandler: Remove unnecessary 'final' modifiers
Update git submodules
AbstractQueryChangesTest: Add method to create change as private
AbstractQueryChangesTest: Fix comment in byPrivate
AbstractQueryChangesTest: Use overloaded newChange method where possible
AbstractQueryChangesTest: Extend testing of visibleto predicate
ChangeQueryBuilder: Rename status_open to statusOpen
ChangeQueryBuilder: Rename is_visible to isVisible
ChangeNotificationsIT: Fix eclipse warning(s) about static use
Extract duplicated code of {Ssh|Http}LogJsonLayout
Add option to log SSH events in JSON format
Remove duplicated constants storing key names of Ssh logs
Add option to log HTTP logging events in JSON format
CacheMetrics: Make F_NAME a final constant in class scope
Fix more cases where Collection.isEmpty() should be used
Use Set instead of EnumSet in method signatures
Replace negation of anyMatch() with noneMatch()
AllExternalIds: Replace lambdas with method references
PostReview: Replace filter and findFirst with anyMatch
XContentBuilder: Use UTF_8 from Java's StandardCharsets rather than Guava
Update git submodules
Update git submodules
Update git submodules
Fail gracefully when a change has an invalid server id
QueryDocumentationExecutor: Make WEIGHTS final and use ImmutableMap
BooleanProjectConfigTransformations: Make MAPPER final
TestSubmitRuleInfo: Make INSTANCE final
TrackingFootersProvider: Make constants final
ChangeCleanupConfig: Make constants final
SetParent: Simplify lambda expression
ProjectsConsistencyChecker: Simplify lambda expression
Remove redundant null checks used with "instanceof"
Remove unnecessary array creation for varargs parameters
Remove redundant parentheses in lambda statements
PreferencesBox: Remove unnecessary boxing to Boolean
GitwebServlet: Rename bufferSize to BUFFER_SIZE and make static
GetPatch: Make FILE_NOT_FOUND static
DeleteZombieCommentsRefs: Make constants static
AbstractNotificationTest: Make constants static and rename
TabFile: Make TRIM final
Remove redundant calls to toString()
OpenIdServiceImpl: Fix incorrect null comparison of Optional
Consistently use isEmpty to check for empty collection
PageLinks: Reuse ADMIN_PROJECTS constant
PageLinks: Fix typo in method name
FlushCaches: Use isEmpty to check for empty list
JGitMetricModule: Replace anonymous Supplier instances with method references
Adapt to deprecation of WindowCacheStats methods in JGit
Documentation: Fix collapsed words and broken link
Use Flogger instead of System.out.println in DeleteZombieCommentsRefs
Fix a dependency injection runtime error in DeleteZombieDrafts pgm
Update git submodules
Upgrade JGit to v5.6.1.202002131546-r
Bazel: Move runtime dependencies only from deps to runtime_deps
Update rename project documentation in project owner guide
Fix issues with caching edited commit message
Use internal navigation instead of hard reload
Fix width of commit message to fit 72 chars
Add "edit" button to diff view
Show files with comments in diff-view file list
Fix missing file name in diff view when file has no change but comments
Remove egit plugin from project owner guide Documentation
Error Prone: Enable and fix OperatorPrecedence
Bazel: Remove superfluous dependencies flagged by unused_deps
Remove Nullable annotation from ProjectIT.getRemoteHead method
GerritBaseTests: Activate test logging
Revert "Enable optional DEBUG level logs for query tests"
Allow to control the Gerrit log level for running tests from system var
Revert "Acceptance: set log threshold level for tests"
Reduce log level for tests to INFO
Bazel: Update time attribute of file entries in plugin artifact
Add Jetty connection metrics
Add additional JGit WindowCache metrics
Update JGit to 5.1.13.202002110435-r
BucketedCallback: fix prune() to remove unset sub-metrics from registry
Modify draft ref updates commits to point to an empty parent
Upgrade gitiles-servlet and blame-cache to 0.2-12
Upgrade JGit to 5.3.7.202002110540-r
Change-Id: I22730db348c53060f75c6954637bbed4ce83f147
This commit is contained in:
@@ -45,6 +45,8 @@ java_library(
|
||||
"//lib/flogger:api",
|
||||
"//lib/guice",
|
||||
"//lib/guice:guice-servlet",
|
||||
"//lib/log:impl-log4j",
|
||||
"//lib/log:log4j",
|
||||
"//lib/truth",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
package com.google.gerrit.testing;
|
||||
|
||||
import com.google.common.base.CharMatcher;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.rules.TestName;
|
||||
import org.junit.rules.TestRule;
|
||||
import org.junit.runner.Description;
|
||||
@@ -23,6 +24,11 @@ import org.junit.runners.model.Statement;
|
||||
public class GerritTestName implements TestRule {
|
||||
private final TestName delegate = new TestName();
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClassTest() {
|
||||
TestLoggingActivator.configureLogging();
|
||||
}
|
||||
|
||||
public String getSanitizedMethodName() {
|
||||
String name = delegate.getMethodName().toLowerCase();
|
||||
name =
|
||||
|
||||
102
java/com/google/gerrit/testing/TestLoggingActivator.java
Normal file
102
java/com/google/gerrit/testing/TestLoggingActivator.java
Normal file
@@ -0,0 +1,102 @@
|
||||
// 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 static org.apache.log4j.Logger.getLogger;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import org.apache.log4j.ConsoleAppender;
|
||||
import org.apache.log4j.Level;
|
||||
import org.apache.log4j.LogManager;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.PatternLayout;
|
||||
|
||||
public class TestLoggingActivator {
|
||||
private static final ImmutableMap<String, Level> LOG_LEVELS =
|
||||
ImmutableMap.<String, Level>builder()
|
||||
.put("com.google.gerrit", getGerritLogLevel())
|
||||
|
||||
// Silence non-critical messages from MINA SSHD.
|
||||
.put("org.apache.mina", Level.WARN)
|
||||
.put("org.apache.sshd.common", Level.WARN)
|
||||
.put("org.apache.sshd.server", Level.WARN)
|
||||
.put("org.apache.sshd.common.keyprovider.FileKeyPairProvider", Level.INFO)
|
||||
.put("com.google.gerrit.sshd.GerritServerSession", Level.WARN)
|
||||
|
||||
// Silence non-critical messages from mime-util.
|
||||
.put("eu.medsea.mimeutil", Level.WARN)
|
||||
|
||||
// Silence non-critical messages from openid4java.
|
||||
.put("org.apache.xml", Level.WARN)
|
||||
.put("org.openid4java", Level.WARN)
|
||||
.put("org.openid4java.consumer.ConsumerManager", Level.FATAL)
|
||||
.put("org.openid4java.discovery.Discovery", Level.ERROR)
|
||||
.put("org.openid4java.server.RealmVerifier", Level.ERROR)
|
||||
.put("org.openid4java.message.AuthSuccess", Level.ERROR)
|
||||
|
||||
// Silence non-critical messages from c3p0 (if used).
|
||||
.put("com.mchange.v2.c3p0", Level.WARN)
|
||||
.put("com.mchange.v2.resourcepool", Level.WARN)
|
||||
.put("com.mchange.v2.sql", Level.WARN)
|
||||
|
||||
// Silence non-critical messages from apache.http.
|
||||
.put("org.apache.http", Level.WARN)
|
||||
|
||||
// Silence non-critical messages from Jetty.
|
||||
.put("org.eclipse.jetty", Level.WARN)
|
||||
|
||||
// Silence non-critical messages from JGit.
|
||||
.put("org.eclipse.jgit.transport.PacketLineIn", Level.WARN)
|
||||
.put("org.eclipse.jgit.transport.PacketLineOut", Level.WARN)
|
||||
.put("org.eclipse.jgit.internal.storage.file.FileSnapshot", Level.WARN)
|
||||
.put("org.eclipse.jgit.util.FS", Level.WARN)
|
||||
.put("org.eclipse.jgit.util.SystemReader", Level.WARN)
|
||||
|
||||
// Silence non-critical messages from Elasticsearch.
|
||||
.put("org.elasticsearch", Level.WARN)
|
||||
|
||||
// Silence non-critical messages from Docker for Elasticsearch query tests.
|
||||
.put("org.testcontainers", Level.WARN)
|
||||
.put("com.github.dockerjava.core", Level.WARN)
|
||||
.build();
|
||||
|
||||
private static Level getGerritLogLevel() {
|
||||
String value = Strings.nullToEmpty(System.getenv("GERRIT_LOG_LEVEL"));
|
||||
if (value.isEmpty()) {
|
||||
value = Strings.nullToEmpty(System.getProperty("gerrit.logLevel"));
|
||||
}
|
||||
return Level.toLevel(value, Level.INFO);
|
||||
}
|
||||
|
||||
public static void configureLogging() {
|
||||
LogManager.resetConfiguration();
|
||||
|
||||
PatternLayout layout = new PatternLayout();
|
||||
layout.setConversionPattern("%-5p %c %x: %m%n");
|
||||
|
||||
ConsoleAppender dst = new ConsoleAppender();
|
||||
dst.setLayout(layout);
|
||||
dst.setTarget("System.err");
|
||||
dst.setThreshold(Level.DEBUG);
|
||||
dst.activateOptions();
|
||||
|
||||
Logger root = LogManager.getRootLogger();
|
||||
root.removeAllAppenders();
|
||||
root.addAppender(dst);
|
||||
|
||||
LOG_LEVELS.entrySet().stream().forEach(e -> getLogger(e.getKey()).setLevel(e.getValue()));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user