Add the ability to increase log lifespan.

This commit is contained in:
Greyson Parrelli
2021-07-20 09:57:17 -04:00
parent 7419da7247
commit 0093e1d3eb
15 changed files with 254 additions and 126 deletions

View File

@@ -57,7 +57,6 @@ public abstract class BaseUnitTest {
PowerMockito.doAnswer(logAnswer).when(Log.class, "i", anyString(), anyString());
PowerMockito.doAnswer(logAnswer).when(Log.class, "w", anyString(), anyString());
PowerMockito.doAnswer(logAnswer).when(Log.class, "e", anyString(), anyString());
PowerMockito.doAnswer(logAnswer).when(Log.class, "wtf", anyString(), anyString());
PowerMockito.doAnswer(new Answer<Boolean>() {
@Override

View File

@@ -3,23 +3,24 @@ package org.thoughtcrime.securesms.testutil;
import org.signal.core.util.logging.Log;
public class EmptyLogger extends Log.Logger {
@Override
public void v(String tag, String message, Throwable t) { }
public EmptyLogger() {
super(0);
}
@Override
public void d(String tag, String message, Throwable t) { }
public void v(String tag, String message, Throwable t, long duration) { }
@Override
public void i(String tag, String message, Throwable t) { }
public void d(String tag, String message, Throwable t, long duration) { }
@Override
public void w(String tag, String message, Throwable t) { }
public void i(String tag, String message, Throwable t, long duration) { }
@Override
public void e(String tag, String message, Throwable t) { }
public void w(String tag, String message, Throwable t, long duration) { }
@Override
public void wtf(String tag, String message, Throwable t) { }
public void e(String tag, String message, Throwable t, long duration) { }
@Override
public void flush() { }

View File

@@ -17,36 +17,35 @@ public final class LogRecorder extends Log.Logger {
private final List<Entry> errors = new ArrayList<>();
private final List<Entry> wtf = new ArrayList<>();
public LogRecorder() {
super(0);
}
@Override
public void v(String tag, String message, Throwable t) {
public void v(String tag, String message, Throwable t, long duration) {
verbose.add(new Entry(tag, message, t));
}
@Override
public void d(String tag, String message, Throwable t) {
public void d(String tag, String message, Throwable t, long duration) {
debug.add(new Entry(tag, message, t));
}
@Override
public void i(String tag, String message, Throwable t) {
public void i(String tag, String message, Throwable t, long duration) {
information.add(new Entry(tag, message, t));
}
@Override
public void w(String tag, String message, Throwable t) {
public void w(String tag, String message, Throwable t, long duration) {
warnings.add(new Entry(tag, message, t));
}
@Override
public void e(String tag, String message, Throwable t) {
public void e(String tag, String message, Throwable t, long duration) {
errors.add(new Entry(tag, message, t));
}
@Override
public void wtf(String tag, String message, Throwable t) {
wtf.add(new Entry(tag, message, t));
}
@Override
public void flush() {
}

View File

@@ -3,36 +3,35 @@ package org.thoughtcrime.securesms.testutil;
import org.signal.core.util.logging.Log;
public final class SystemOutLogger extends Log.Logger {
public SystemOutLogger() {
super(0);
}
@Override
public void v(String tag, String message, Throwable t) {
public void v(String tag, String message, Throwable t, long duration) {
printlnFormatted('v', tag, message, t);
}
@Override
public void d(String tag, String message, Throwable t) {
public void d(String tag, String message, Throwable t, long duration) {
printlnFormatted('d', tag, message, t);
}
@Override
public void i(String tag, String message, Throwable t) {
public void i(String tag, String message, Throwable t, long duration) {
printlnFormatted('i', tag, message, t);
}
@Override
public void w(String tag, String message, Throwable t) {
public void w(String tag, String message, Throwable t, long duration) {
printlnFormatted('w', tag, message, t);
}
@Override
public void e(String tag, String message, Throwable t) {
public void e(String tag, String message, Throwable t, long duration) {
printlnFormatted('e', tag, message, t);
}
@Override
public void wtf(String tag, String message, Throwable t) {
printlnFormatted('x', tag, message, t);
}
@Override
public void flush() { }