|
|
@ -17,6 +17,7 @@ import java.util.Arrays;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.LinkedList;
|
|
|
|
import java.util.LinkedList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.concurrent.CountDownLatch;
|
|
|
|
import java.util.concurrent.Executor;
|
|
|
|
import java.util.concurrent.Executor;
|
|
|
|
import java.util.concurrent.Executors;
|
|
|
|
import java.util.concurrent.Executors;
|
|
|
|
|
|
|
|
|
|
|
@ -47,7 +48,7 @@ public class PersistentLogger extends Log.Logger {
|
|
|
|
this.context = context.getApplicationContext();
|
|
|
|
this.context = context.getApplicationContext();
|
|
|
|
this.secret = LogSecretProvider.getOrCreateAttachmentSecret(context);
|
|
|
|
this.secret = LogSecretProvider.getOrCreateAttachmentSecret(context);
|
|
|
|
this.executor = Executors.newSingleThreadExecutor(r -> {
|
|
|
|
this.executor = Executors.newSingleThreadExecutor(r -> {
|
|
|
|
Thread thread = new Thread(r, "logger");
|
|
|
|
Thread thread = new Thread(r, "PersistentLogger");
|
|
|
|
thread.setPriority(Thread.MIN_PRIORITY);
|
|
|
|
thread.setPriority(Thread.MIN_PRIORITY);
|
|
|
|
return thread;
|
|
|
|
return thread;
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -85,6 +86,19 @@ public class PersistentLogger extends Log.Logger {
|
|
|
|
write(LOG_WTF, tag, message, t);
|
|
|
|
write(LOG_WTF, tag, message, t);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void blockUntilAllWritesFinished() {
|
|
|
|
|
|
|
|
CountDownLatch latch = new CountDownLatch(1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
executor.execute(latch::countDown);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
latch.await();
|
|
|
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
|
|
|
android.util.Log.w(TAG, "Failed to wait for all writes.");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@WorkerThread
|
|
|
|
@WorkerThread
|
|
|
|
public ListenableFuture<String> getLogs() {
|
|
|
|
public ListenableFuture<String> getLogs() {
|
|
|
|
final SettableFuture<String> future = new SettableFuture<>();
|
|
|
|
final SettableFuture<String> future = new SettableFuture<>();
|
|
|
|