diff --git a/WORKSPACE b/WORKSPACE index 5de2ec2332..ef9e9f6069 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -171,6 +171,26 @@ maven_jar( sha1 = "94ad16d728b374d65bd897625f3fbb3da223a2b6", ) +FLOGGER_VERS = "0.2" + +maven_jar( + name = "flogger", + artifact = "com.google.flogger:flogger:" + FLOGGER_VERS, + sha1 = "a22d04ed3b84bae8ecf8aa6d4430ad000bcdf7b4", +) + +maven_jar( + name = "flogger-log4j-backend", + artifact = "com.google.flogger:flogger-log4j-backend:" + FLOGGER_VERS, + sha1 = "d5085e3996bddc4b105d53b886190cc9a8811a9e", +) + +maven_jar( + name = "flogger-system-backend", + artifact = "com.google.flogger:flogger-system-backend:" + FLOGGER_VERS, + sha1 = "b995c84b8443d6cfbd011a55719b63494b974c3a", +) + maven_jar( name = "gwtjsonrpc", artifact = "com.google.gerrit:gwtjsonrpc:1.11", diff --git a/java/Main.java b/java/Main.java index 0eca665f8f..f26b6dfa8c 100644 --- a/java/Main.java +++ b/java/Main.java @@ -13,6 +13,8 @@ // limitations under the License. public final class Main { + private static final String FLOGGER_BACKEND_PROPERTY = "flogger.backend_factory"; + // We don't do any real work here because we need to import // the archive lookup code and we cannot import a class in // the default package. So this is just a tiny springboard @@ -21,6 +23,7 @@ public final class Main { public static void main(String[] argv) throws Exception { if (onSupportedJavaVersion()) { + configureFloggerBackend(); com.google.gerrit.launcher.GerritLauncher.main(argv); } else { @@ -38,6 +41,18 @@ public final class Main { return false; } + private static void configureFloggerBackend() { + if (System.getProperty(FLOGGER_BACKEND_PROPERTY) != null) { + // Flogger backend is already configured + return; + } + + // Configure log4j backend + System.setProperty( + FLOGGER_BACKEND_PROPERTY, + "com.google.common.flogger.backend.log4j.Log4jBackendFactory#getInstance"); + } + private static double parse(String version) { if (version == null || version.length() == 0) { return 0.0; diff --git a/java/com/google/gerrit/pgm/util/BUILD b/java/com/google/gerrit/pgm/util/BUILD index 91647fbc83..8f3bd4b273 100644 --- a/java/com/google/gerrit/pgm/util/BUILD +++ b/java/com/google/gerrit/pgm/util/BUILD @@ -21,6 +21,7 @@ java_library( "//lib:guava", "//lib:gwtorm", "//lib/commons:dbcp", + "//lib/flogger:api", "//lib/guice", "//lib/jgit/org.eclipse.jgit:jgit", "//lib/log:api", diff --git a/lib/flogger/BUILD b/lib/flogger/BUILD new file mode 100644 index 0000000000..c41e12f224 --- /dev/null +++ b/lib/flogger/BUILD @@ -0,0 +1,10 @@ +java_library( + name = "api", + data = ["//lib:LICENSE-Apache2.0"], + visibility = ["//visibility:public"], + exports = [ + "@flogger-log4j-backend//jar", + "@flogger-system-backend//jar", + "@flogger//jar", + ], +) diff --git a/lib/jgit/org.eclipse.jgit/BUILD b/lib/jgit/org.eclipse.jgit/BUILD index 5586cb10f3..caf8eecf10 100644 --- a/lib/jgit/org.eclipse.jgit/BUILD +++ b/lib/jgit/org.eclipse.jgit/BUILD @@ -5,7 +5,10 @@ java_library( data = ["//lib:LICENSE-jgit"], visibility = ["//visibility:public"], exports = [jgit_dep("@jgit_lib//jar")], - runtime_deps = [":javaewah"], + runtime_deps = [ + ":javaewah", + "//lib/log:api", + ], ) alias(