diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2021-11-24 23:11:36 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2021-11-24 23:12:08 +0100 |
commit | 75c716f5d7cdb0f4978c42a4dcae6c6ee4dcb42d (patch) | |
tree | 91bcf5b47bbef0a88acad5c6bbe32fdbd8a9b1d4 /org.eclipse.jgit.junit.http/src | |
parent | c05d711bb757b0e2705bb22b9710b6be6eb37d99 (diff) | |
download | jgit-75c716f5d7cdb0f4978c42a4dcae6c6ee4dcb42d.tar.gz jgit-75c716f5d7cdb0f4978c42a4dcae6c6ee4dcb42d.zip |
Implement RecordingLogger based on org.slf4j.Logger
Jetty 10 uses slf4j for logging and deprecated its own Logger interface
org.eclipse.jetty.util.log.Logger.
Change-Id: I1b0c3a23e43190a50987175973725c3ad6e32f5f
Diffstat (limited to 'org.eclipse.jgit.junit.http/src')
-rw-r--r-- | org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/RecordingLogger.java | 198 |
1 files changed, 95 insertions, 103 deletions
diff --git a/org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/RecordingLogger.java b/org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/RecordingLogger.java index d2ef733d74..9c3c980ad8 100644 --- a/org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/RecordingLogger.java +++ b/org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/RecordingLogger.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010, Google Inc. and others + * Copyright (C) 2010, 2021 Google Inc. and others * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0 which is available at @@ -7,7 +7,6 @@ * * SPDX-License-Identifier: BSD-3-Clause */ - package org.eclipse.jgit.junit.http; import java.text.MessageFormat; @@ -15,12 +14,12 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import org.eclipse.jetty.util.log.Logger; +import org.slf4j.helpers.MarkerIgnoringBase; + +public class RecordingLogger extends MarkerIgnoringBase { + + private static final long serialVersionUID = 1L; -/** - * Log warnings into an array for later inspection. - */ -public class RecordingLogger implements Logger { private static List<Warning> warnings = new ArrayList<>(); /** @@ -60,8 +59,6 @@ public class RecordingLogger implements Logger { } } - private final String name; - /** * Constructor for <code>RecordingLogger</code>. */ @@ -78,171 +75,166 @@ public class RecordingLogger implements Logger { this.name = name; } - /** {@inheritDoc} */ @Override - public Logger getLogger(@SuppressWarnings("hiding") String name) { - return new RecordingLogger(name); + public boolean isTraceEnabled() { + // Ignore (not relevant to test failures) + return false; } - /** {@inheritDoc} */ @Override - public String getName() { - return name; + public void trace(String msg) { + // Ignore (not relevant to test failures) } - /** - * Warning - * - * @param msg - * @param arg0 - * @param arg1 - */ - public void warn(String msg, Object arg0, Object arg1) { - synchronized (warnings) { - warnings.add(new Warning(MessageFormat.format(msg, arg0, arg1))); - } + @Override + public void trace(String format, Object arg) { + // Ignore (not relevant to test failures) } - /** {@inheritDoc} */ @Override - public void warn(String msg, Throwable th) { - synchronized (warnings) { - warnings.add(new Warning(msg, th)); - } + public void trace(String format, Object arg1, Object arg2) { + // Ignore (not relevant to test failures) } - /** - * Warning - * - * @param msg - * warning message - */ - public void warn(String msg) { - synchronized (warnings) { - warnings.add(new Warning(msg)); - } + @Override + public void trace(String format, Object... arguments) { + // Ignore (not relevant to test failures) } - /** - * Debug log - * - * @param msg - * @param arg0 - * @param arg1 - */ - public void debug(String msg, Object arg0, Object arg1) { + @Override + public void trace(String msg, Throwable t) { // Ignore (not relevant to test failures) } - /** {@inheritDoc} */ @Override - public void debug(String msg, Throwable th) { - // Ignore (not relevant to test failures) + public boolean isDebugEnabled() { + return false; } - /** - * Debug log - * - * @param msg - * debug message - */ + @Override public void debug(String msg) { // Ignore (not relevant to test failures) } - /** - * Info - * - * @param msg - * @param arg0 - * @param arg1 - */ - public void info(String msg, Object arg0, Object arg1) { + @Override + public void debug(String format, Object arg) { // Ignore (not relevant to test failures) } - /** - * Info - * - * @param msg - */ - public void info(String msg) { + @Override + public void debug(String format, Object arg1, Object arg2) { // Ignore (not relevant to test failures) } - /** {@inheritDoc} */ @Override - public boolean isDebugEnabled() { + public void debug(String format, Object... arguments) { + // Ignore (not relevant to test failures) + } + + @Override + public void debug(String msg, Throwable t) { + // Ignore (not relevant to test failures) + } + + @Override + public boolean isInfoEnabled() { return false; } - /** {@inheritDoc} */ @Override - public void setDebugEnabled(boolean enabled) { + public void info(String msg) { + // Ignore (not relevant to test failures) + } + + @Override + public void info(String format, Object arg) { + // Ignore (not relevant to test failures) + } + + @Override + public void info(String format, Object arg1, Object arg2) { + // Ignore (not relevant to test failures) + } + + @Override + public void info(String format, Object... arguments) { + // Ignore (not relevant to test failures) + } + + @Override + public void info(String msg, Throwable t) { // Ignore (not relevant to test failures) } - /** {@inheritDoc} */ @Override - public void warn(String msg, Object... args) { + public boolean isWarnEnabled() { + return true; + } + + @Override + public void warn(String msg) { + synchronized (warnings) { + warnings.add(new Warning(msg)); + } + } + + @Override + public void warn(String format, Object arg) { + warn(format, Collections.singleton(arg)); + } + + @Override + public void warn(String format, Object... arguments) { synchronized (warnings) { int i = 0; - int index = msg.indexOf("{}"); + int index = format.indexOf("{}"); while (index >= 0) { - msg = msg.replaceFirst("\\{\\}", "{" + i++ + "}"); - index = msg.indexOf("{}"); + format = format.replaceFirst("\\{\\}", "{" + i++ + "}"); + index = format.indexOf("{}"); } - warnings.add(new Warning(MessageFormat.format(msg, args))); + warnings.add(new Warning(MessageFormat.format(format, arguments))); } } - /** {@inheritDoc} */ @Override - public void warn(Throwable thrown) { - synchronized (warnings) { - warnings.add(new Warning(thrown)); - } + public void warn(String format, Object arg1, Object arg2) { + warn(format, new Object[] { arg1, arg2 }); } - /** {@inheritDoc} */ @Override - public void info(String msg, Object... args) { - // Ignore (not relevant to test failures) + public void warn(String msg, Throwable t) { + synchronized (warnings) { + warnings.add(new Warning(msg, t)); + } } - /** {@inheritDoc} */ @Override - public void info(Throwable thrown) { - // Ignore (not relevant to test failures) + public boolean isErrorEnabled() { + return false; } - /** {@inheritDoc} */ @Override - public void info(String msg, Throwable thrown) { + public void error(String msg) { // Ignore (not relevant to test failures) } - /** {@inheritDoc} */ @Override - public void debug(String msg, Object... args) { + public void error(String format, Object arg) { // Ignore (not relevant to test failures) } - /** {@inheritDoc} */ @Override - public void debug(Throwable thrown) { + public void error(String format, Object arg1, Object arg2) { // Ignore (not relevant to test failures) } - /** {@inheritDoc} */ @Override - public void ignore(Throwable arg0) { + public void error(String format, Object... arguments) { // Ignore (not relevant to test failures) } - /** {@inheritDoc} */ @Override - public void debug(String msg, long value) { + public void error(String msg, Throwable t) { // Ignore (not relevant to test failures) } } |