Add the ability to increase log lifespan.

fork-5.53.8
Greyson Parrelli 2021-07-20 09:57:17 -04:00
rodzic 7419da7247
commit 0093e1d3eb
15 zmienionych plików z 254 dodań i 126 usunięć

Wyświetl plik

@ -151,7 +151,7 @@ class LogDatabase private constructor(
class Reader(private val cursor: Cursor) : Iterator<String>, Closeable {
override fun hasNext(): Boolean {
return !cursor.isLast
return !cursor.isLast && cursor.count > 0
}
override fun next(): String {

Wyświetl plik

@ -156,6 +156,8 @@ public class RecipientDatabase extends Database {
private static final String IDENTITY_STATUS = "identity_status";
private static final String IDENTITY_KEY = "identity_key";
static final long IMPORTANT_LOG_DURATION = TimeUnit.DAYS.toMillis(7);
/**
* Values that represent the index in the capabilities bitmask. Each index can store a 2-bit
* value, which in this case is the value of {@link Recipient.Capability}.
@ -438,7 +440,7 @@ public class RecipientDatabase extends Database {
RecipientId finalId;
if (!byE164.isPresent() && !byUuid.isPresent()) {
Log.i(TAG, "Discovered a completely new user. Inserting.");
Log.i(TAG, "Discovered a completely new user. Inserting.", IMPORTANT_LOG_DURATION);
if (highTrust) {
long id = db.insert(TABLE_NAME, null, buildContentValuesForNewUser(e164, uuid));
finalId = RecipientId.from(id);
@ -451,7 +453,7 @@ public class RecipientDatabase extends Database {
RecipientSettings e164Settings = getRecipientSettings(byE164.get());
if (e164Settings.uuid != null) {
if (highTrust) {
Log.w(TAG, "Found out about a UUID for a known E164 user, but that user already has a UUID. Likely a case of re-registration. High-trust, so stripping the E164 from the existing account and assigning it to a new entry.");
Log.w(TAG, String.format(Locale.US, "Found out about a UUID (%s) for a known E164 user (%s), but that user already has a UUID (%s). Likely a case of re-registration. High-trust, so stripping the E164 from the existing account and assigning it to a new entry.", uuid, byE164.get(), e164Settings.uuid), IMPORTANT_LOG_DURATION);
removePhoneNumber(byE164.get(), db);
recipientNeedingRefresh = byE164.get();
@ -462,18 +464,18 @@ public class RecipientDatabase extends Database {
long id = db.insert(TABLE_NAME, null, insertValues);
finalId = RecipientId.from(id);
} else {
Log.w(TAG, "Found out about a UUID for a known E164 user, but that user already has a UUID. Likely a case of re-registration. Low-trust, so making a new user for the UUID.");
Log.w(TAG, String.format(Locale.US, "Found out about a UUID (%s) for a known E164 user (%s), but that user already has a UUID (%s). Likely a case of re-registration. Low-trust, so making a new user for the UUID.", uuid, byE164.get(), e164Settings.uuid), IMPORTANT_LOG_DURATION);
long id = db.insert(TABLE_NAME, null, buildContentValuesForNewUser(null, uuid));
finalId = RecipientId.from(id);
}
} else {
if (highTrust) {
Log.i(TAG, "Found out about a UUID for a known E164 user. High-trust, so updating.");
Log.i(TAG, String.format(Locale.US, "Found out about a UUID (%s) for a known E164 user (%s). High-trust, so updating.", uuid, byE164.get()), IMPORTANT_LOG_DURATION);
markRegisteredOrThrow(byE164.get(), uuid);
finalId = byE164.get();
} else {
Log.i(TAG, "Found out about a UUID for a known E164 user. Low-trust, so making a new user for the UUID.");
Log.i(TAG, String.format(Locale.US, "Found out about a UUID (%s) for a known E164 user (%s). Low-trust, so making a new user for the UUID.", uuid, byE164.get()), IMPORTANT_LOG_DURATION);
long id = db.insert(TABLE_NAME, null, buildContentValuesForNewUser(null, uuid));
finalId = RecipientId.from(id);
}
@ -484,11 +486,11 @@ public class RecipientDatabase extends Database {
} else if (!byE164.isPresent() && byUuid.isPresent()) {
if (e164 != null) {
if (highTrust) {
Log.i(TAG, "Found out about an E164 for a known UUID user. High-trust, so updating.");
Log.i(TAG, String.format(Locale.US, "Found out about an E164 (%s) for a known UUID user (%s). High-trust, so updating.", e164, byUuid.get()), IMPORTANT_LOG_DURATION);
setPhoneNumberOrThrow(byUuid.get(), e164);
finalId = byUuid.get();
} else {
Log.i(TAG, "Found out about an E164 for a known UUID user. Low-trust, so doing nothing.");
Log.i(TAG, String.format(Locale.US, "Found out about an E164 (%s) for a known UUID user (%s). Low-trust, so doing nothing.", e164, byUuid.get()), IMPORTANT_LOG_DURATION);
finalId = byUuid.get();
}
} else {
@ -498,13 +500,13 @@ public class RecipientDatabase extends Database {
if (byE164.equals(byUuid)) {
finalId = byUuid.get();
} else {
Log.w(TAG, "Hit a conflict between " + byE164.get() + " (E164) and " + byUuid.get() + " (UUID). They map to different recipients.", new Throwable());
Log.w(TAG, String.format(Locale.US, "Hit a conflict between %s (E164 of %s) and %s (UUID %s). They map to different recipients.", byE164.get(), e164, byUuid.get(), uuid), new Throwable(), IMPORTANT_LOG_DURATION);
RecipientSettings e164Settings = getRecipientSettings(byE164.get());
if (e164Settings.getUuid() != null) {
if (highTrust) {
Log.w(TAG, "The E164 contact has a different UUID. Likely a case of re-registration. High-trust, so stripping the E164 from the existing account and assigning it to the UUID entry.");
Log.w(TAG, "The E164 contact has a different UUID. Likely a case of re-registration. High-trust, so stripping the E164 from the existing account and assigning it to the UUID entry.", IMPORTANT_LOG_DURATION);
removePhoneNumber(byE164.get(), db);
recipientNeedingRefresh = byE164.get();
@ -513,17 +515,17 @@ public class RecipientDatabase extends Database {
finalId = byUuid.get();
} else {
Log.w(TAG, "The E164 contact has a different UUID. Likely a case of re-registration. Low-trust, so doing nothing.");
Log.w(TAG, "The E164 contact has a different UUID. Likely a case of re-registration. Low-trust, so doing nothing.", IMPORTANT_LOG_DURATION);
finalId = byUuid.get();
}
} else {
if (highTrust) {
Log.w(TAG, "We have one contact with just an E164, and another with UUID. High-trust, so merging the two rows together.");
Log.w(TAG, "We have one contact with just an E164, and another with UUID. High-trust, so merging the two rows together.", IMPORTANT_LOG_DURATION);
finalId = merge(byUuid.get(), byE164.get());
recipientNeedingRefresh = byUuid.get();
remapped = new Pair<>(byE164.get(), byUuid.get());
} else {
Log.w(TAG, "We have one contact with just an E164, and another with UUID. Low-trust, so doing nothing.");
Log.w(TAG, "We have one contact with just an E164, and another with UUID. Low-trust, so doing nothing.", IMPORTANT_LOG_DURATION);
finalId = byUuid.get();
}
}
@ -2879,7 +2881,7 @@ public class RecipientDatabase extends Database {
RecipientSettings e164Settings = getRecipientSettings(byE164);
// Recipient
Log.w(TAG, "Deleting recipient " + byE164);
Log.w(TAG, "Deleting recipient " + byE164, IMPORTANT_LOG_DURATION);
db.delete(TABLE_NAME, ID_WHERE, SqlUtil.buildArgs(byE164));
RemappedRecords.getInstance().addRecipient(context, byE164, byUuid);
@ -2964,17 +2966,17 @@ public class RecipientDatabase extends Database {
boolean hasUuidSession = DatabaseFactory.getSessionDatabase(context).getAllFor(byUuid).size() > 0;
if (hasE164Session && hasUuidSession) {
Log.w(TAG, "Had a session for both users. Deleting the E164.");
Log.w(TAG, "Had a session for both users. Deleting the E164.", IMPORTANT_LOG_DURATION);
db.delete(SessionDatabase.TABLE_NAME, SessionDatabase.RECIPIENT_ID + " = ?", SqlUtil.buildArgs(byE164));
} else if (hasE164Session && !hasUuidSession) {
Log.w(TAG, "Had a session for E164, but not UUID. Re-assigning to the UUID.");
Log.w(TAG, "Had a session for E164, but not UUID. Re-assigning to the UUID.", IMPORTANT_LOG_DURATION);
ContentValues values = new ContentValues();
values.put(SessionDatabase.RECIPIENT_ID, byUuid.serialize());
db.update(SessionDatabase.TABLE_NAME, values, SessionDatabase.RECIPIENT_ID + " = ?", SqlUtil.buildArgs(byE164));
} else if (!hasE164Session && hasUuidSession) {
Log.w(TAG, "Had a session for UUID, but not E164. No action necessary.");
Log.w(TAG, "Had a session for UUID, but not E164. No action necessary.", IMPORTANT_LOG_DURATION);
} else {
Log.w(TAG, "Had no sessions. No action necessary.");
Log.w(TAG, "Had no sessions. No action necessary.", IMPORTANT_LOG_DURATION);
}
// Mentions

Wyświetl plik

@ -1276,16 +1276,16 @@ public class ThreadDatabase extends Database {
throw new IllegalStateException("Must be in a transaction!");
}
Log.w(TAG, "Merging threads. Primary: " + primaryRecipientId + ", Secondary: " + secondaryRecipientId);
Log.w(TAG, "Merging threads. Primary: " + primaryRecipientId + ", Secondary: " + secondaryRecipientId, RecipientDatabase.IMPORTANT_LOG_DURATION);
ThreadRecord primary = getThreadRecord(getThreadIdFor(primaryRecipientId));
ThreadRecord secondary = getThreadRecord(getThreadIdFor(secondaryRecipientId));
if (primary != null && secondary == null) {
Log.w(TAG, "[merge] Only had a thread for primary. Returning that.");
Log.w(TAG, "[merge] Only had a thread for primary. Returning that.", RecipientDatabase.IMPORTANT_LOG_DURATION);
return new MergeResult(primary.getThreadId(), -1, false);
} else if (primary == null && secondary != null) {
Log.w(TAG, "[merge] Only had a thread for secondary. Updating it to have the recipientId of the primary.");
Log.w(TAG, "[merge] Only had a thread for secondary. Updating it to have the recipientId of the primary.", RecipientDatabase.IMPORTANT_LOG_DURATION);
ContentValues values = new ContentValues();
values.put(RECIPIENT_ID, primaryRecipientId.serialize());
@ -1296,7 +1296,7 @@ public class ThreadDatabase extends Database {
Log.w(TAG, "[merge] No thread for either.");
return new MergeResult(-1, -1, false);
} else {
Log.w(TAG, "[merge] Had a thread for both. Deleting the secondary and merging the attributes together.");
Log.w(TAG, "[merge] Had a thread for both. Deleting the secondary and merging the attributes together.", RecipientDatabase.IMPORTANT_LOG_DURATION);
SQLiteDatabase db = databaseHelper.getWritableDatabase();

Wyświetl plik

@ -20,10 +20,8 @@ public class CustomSignalProtocolLogger implements SignalProtocolLogger {
Log.w(tag, message);
break;
case ERROR:
Log.e(tag, message);
break;
case ASSERT:
Log.wtf(tag, message);
Log.e(tag, message);
break;
}
}

Wyświetl plik

@ -25,7 +25,7 @@ import java.util.Locale
class PersistentLogger(
application: Application,
defaultLifespan: Long
) : Log.Logger() {
) : Log.Logger(defaultLifespan) {
companion object {
private const val LOG_V = "V"
@ -41,41 +41,37 @@ class PersistentLogger(
private val cachedThreadString: ThreadLocal<String> = ThreadLocal()
init {
WriteThread(logEntries, logDatabase, defaultLifespan).apply {
WriteThread(logEntries, logDatabase).apply {
priority = Thread.MIN_PRIORITY
}.start()
}
override fun v(tag: String?, message: String?, t: Throwable?) {
write(LOG_V, tag, message, t)
override fun v(tag: String?, message: String?, t: Throwable?, duration: Long) {
write(LOG_V, tag, message, t, duration)
}
override fun d(tag: String?, message: String?, t: Throwable?) {
write(LOG_D, tag, message, t)
override fun d(tag: String?, message: String?, t: Throwable?, duration: Long) {
write(LOG_D, tag, message, t, duration)
}
override fun i(tag: String?, message: String?, t: Throwable?) {
write(LOG_I, tag, message, t)
override fun i(tag: String?, message: String?, t: Throwable?, duration: Long) {
write(LOG_I, tag, message, t, duration)
}
override fun w(tag: String?, message: String?, t: Throwable?) {
write(LOG_W, tag, message, t)
override fun w(tag: String?, message: String?, t: Throwable?, duration: Long) {
write(LOG_W, tag, message, t, duration)
}
override fun e(tag: String?, message: String?, t: Throwable?) {
write(LOG_E, tag, message, t)
}
override fun wtf(tag: String?, message: String?, t: Throwable?) {
write(LOG_WTF, tag, message, t)
override fun e(tag: String?, message: String?, t: Throwable?, duration: Long) {
write(LOG_E, tag, message, t, duration)
}
override fun flush() {
logEntries.blockForFlushed()
}
private fun write(level: String, tag: String?, message: String?, t: Throwable?) {
logEntries.add(LogRequest(level, tag ?: "null", message, Date(), getThreadString(), t))
private fun write(level: String, tag: String?, message: String?, t: Throwable?, lifespan: Long) {
logEntries.add(LogRequest(level, tag ?: "null", message, Date(), getThreadString(), t, lifespan))
}
private fun getThreadString(): String {
@ -100,13 +96,13 @@ class PersistentLogger(
val message: String?,
val date: Date,
val threadString: String,
val throwable: Throwable?
val throwable: Throwable?,
val lifespan: Long
)
private class WriteThread(
private val requests: LogRequests,
private val db: LogDatabase,
private val defaultLifespan: Long
private val db: LogDatabase
) : Thread("signal-logger") {
private val dateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS zzz", Locale.US)
@ -127,7 +123,7 @@ class PersistentLogger(
out.add(
LogEntry(
createdAt = request.date.time,
lifespan = defaultLifespan,
lifespan = request.lifespan,
body = formatBody(request.threadString, request.date, request.level, request.tag, request.message)
)
)
@ -142,7 +138,7 @@ class PersistentLogger(
val entries = lines.map { line ->
LogEntry(
createdAt = request.date.time,
lifespan = defaultLifespan,
lifespan = request.lifespan,
body = formatBody(request.threadString, request.date, request.level, request.tag, line)
)
}

Wyświetl plik

@ -39,10 +39,8 @@ final class MobileCoinLogAdapter implements LogAdapter {
Log.w(tag, message, throwable);
break;
case ERROR:
Log.e(tag, message, throwable);
break;
case WTF:
Log.wtf(tag, message, throwable);
Log.e(tag, message, throwable);
break;
}
}

Wyświetl plik

@ -6,6 +6,8 @@ import org.signal.core.util.logging.Log;
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
import java.util.concurrent.TimeUnit;
public class SignalUncaughtExceptionHandler implements Thread.UncaughtExceptionHandler {
private static final String TAG = Log.tag(SignalUncaughtExceptionHandler.class);
@ -17,8 +19,8 @@ public class SignalUncaughtExceptionHandler implements Thread.UncaughtExceptionH
}
@Override
public void uncaughtException(Thread t, Throwable e) {
Log.e(TAG, "", e);
public void uncaughtException(@NonNull Thread t, @NonNull Throwable e) {
Log.e(TAG, "", e, TimeUnit.DAYS.toMillis(7));
SignalStore.blockUntilAllWritesFinished();
Log.blockUntilAllWritesFinished();
ApplicationDependencies.getJobManager().flush();

Wyświetl plik

@ -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

Wyświetl plik

@ -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() { }

Wyświetl plik

@ -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() {
}

Wyświetl plik

@ -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() { }

Wyświetl plik

@ -5,36 +5,35 @@ import android.annotation.SuppressLint;
@SuppressLint("LogNotSignal")
public final class AndroidLogger extends Log.Logger {
public AndroidLogger() {
super(0);
}
@Override
public void v(String tag, String message, Throwable t) {
public void v(String tag, String message, Throwable t, long lifespan) {
android.util.Log.v(tag, message, t);
}
@Override
public void d(String tag, String message, Throwable t) {
public void d(String tag, String message, Throwable t, long lifespan) {
android.util.Log.d(tag, message, t);
}
@Override
public void i(String tag, String message, Throwable t) {
public void i(String tag, String message, Throwable t, long lifespan) {
android.util.Log.i(tag, message, t);
}
@Override
public void w(String tag, String message, Throwable t) {
public void w(String tag, String message, Throwable t, long lifespan) {
android.util.Log.w(tag, message, t);
}
@Override
public void e(String tag, String message, Throwable t) {
public void e(String tag, String message, Throwable t, long lifespan) {
android.util.Log.e(tag, message, t);
}
@Override
public void wtf(String tag, String message, Throwable t) {
android.util.Log.wtf(tag, message, t);
}
@Override
public void flush() {
}

Wyświetl plik

@ -11,48 +11,112 @@ class CompoundLogger extends Log.Logger {
private final Log.Logger[] loggers;
CompoundLogger(@NonNull Log.Logger... loggers) {
super(0);
this.loggers = loggers;
}
@Override
public void v(String tag, String message, Throwable t) {
public void v(String tag, String message, Throwable t, long duration) {
for (Log.Logger logger : loggers) {
logger.v(tag, message, t, duration);
}
}
@Override
public void d(String tag, String message, Throwable t, long duration) {
for (Log.Logger logger : loggers) {
logger.d(tag, message, t, duration);
}
}
@Override
public void i(String tag, String message, Throwable t, long duration) {
for (Log.Logger logger : loggers) {
logger.i(tag, message, t, duration);
}
}
@Override
public void w(String tag, String message, Throwable t, long duration) {
for (Log.Logger logger : loggers) {
logger.w(tag, message, t, duration);
}
}
@Override
public void e(String tag, String message, Throwable t, long duration) {
for (Log.Logger logger : loggers) {
logger.e(tag, message, t, duration);
}
}
@Override
public void v(String tag, String message, Throwable t) {
for (Log.Logger logger :loggers) {
logger.v(tag, message, t);
}
}
@Override
public void d(String tag, String message, Throwable t) {
for (Log.Logger logger : loggers) {
for (Log.Logger logger :loggers) {
logger.d(tag, message, t);
}
}
@Override
public void i(String tag, String message, Throwable t) {
for (Log.Logger logger : loggers) {
for (Log.Logger logger :loggers) {
logger.i(tag, message, t);
}
}
@Override
public void w(String tag, String message, Throwable t) {
for (Log.Logger logger : loggers) {
for (Log.Logger logger :loggers) {
logger.w(tag, message, t);
}
}
@Override
public void e(String tag, String message, Throwable t) {
for (Log.Logger logger : loggers) {
for (Log.Logger logger :loggers) {
logger.e(tag, message, t);
}
}
@Override
public void wtf(String tag, String message, Throwable t) {
for (Log.Logger logger : loggers) {
logger.wtf(tag, message, t);
public void v(String tag, String message) {
for (Log.Logger logger :loggers) {
logger.v(tag, message);
}
}
@Override
public void d(String tag, String message) {
for (Log.Logger logger :loggers) {
logger.d(tag, message);
}
}
@Override
public void i(String tag, String message) {
for (Log.Logger logger :loggers) {
logger.i(tag, message);
}
}
@Override
public void w(String tag, String message) {
for (Log.Logger logger :loggers) {
logger.w(tag, message);
}
}
@Override
public void e(String tag, String message) {
for (Log.Logger logger :loggers) {
logger.e(tag, message);
}
}

Wyświetl plik

@ -47,10 +47,6 @@ public final class Log {
e(tag, message, null);
}
public static void wtf(String tag, String message) {
wtf(tag, message, null);
}
public static void v(String tag, Throwable t) {
v(tag, null, t);
}
@ -71,10 +67,6 @@ public final class Log {
e(tag, null, t);
}
public static void wtf(String tag, Throwable t) {
wtf(tag, null, t);
}
public static void v(String tag, String message, Throwable t) {
logger.v(tag, message, t);
}
@ -95,8 +87,44 @@ public final class Log {
logger.e(tag, message, t);
}
public static void wtf(String tag, String message, Throwable t) {
logger.wtf(tag, message, t);
public static void v(String tag, String message, long duration) {
logger.v(tag, message, duration);
}
public static void d(String tag, String message, long duration) {
logger.d(tag, message, duration);
}
public static void i(String tag, String message, long duration) {
logger.i(tag, message, duration);
}
public static void w(String tag, String message, long duration) {
logger.w(tag, message, duration);
}
public static void e(String tag, String message, long duration) {
logger.e(tag, message, duration);
}
public static void v(String tag, String message, Throwable t, long duration) {
logger.v(tag, message, t, duration);
}
public static void d(String tag, String message, Throwable t, long duration) {
logger.d(tag, message, t, duration);
}
public static void i(String tag, String message, Throwable t, long duration) {
logger.i(tag, message, t, duration);
}
public static void w(String tag, String message, Throwable t, long duration) {
logger.w(tag, message, t, duration);
}
public static void e(String tag, String message, Throwable t, long duration) {
logger.e(tag, message, t, duration);
}
public static String tag(Class<?> clazz) {
@ -126,14 +154,60 @@ public final class Log {
}
public static abstract class Logger {
public abstract void v(String tag, String message, Throwable t);
public abstract void d(String tag, String message, Throwable t);
public abstract void i(String tag, String message, Throwable t);
public abstract void w(String tag, String message, Throwable t);
public abstract void e(String tag, String message, Throwable t);
public abstract void wtf(String tag, String message, Throwable t);
private final long defaultLifespan;
protected Logger(long defaultLifespan) {
this.defaultLifespan = defaultLifespan;
}
public abstract void v(String tag, String message, Throwable t, long lifespan);
public abstract void d(String tag, String message, Throwable t, long lifespan);
public abstract void i(String tag, String message, Throwable t, long lifespan);
public abstract void w(String tag, String message, Throwable t, long lifespan);
public abstract void e(String tag, String message, Throwable t, long lifespan);
public abstract void flush();
public void v(String tag, String message, long lifespan) {
v(tag, message, null, lifespan);
}
public void d(String tag, String message, long lifespan) {
d(tag, message, null, lifespan);
}
public void i(String tag, String message, long lifespan) {
i(tag, message, null, lifespan);
}
public void w(String tag, String message, long lifespan) {
w(tag, message, null, lifespan);
}
public void e(String tag, String message, long lifespan) {
e(tag, message, null, lifespan);
}
public void v(String tag, String message, Throwable t) {
v(tag, message, t, defaultLifespan);
}
public void d(String tag, String message, Throwable t) {
d(tag, message, t, defaultLifespan);
}
public void i(String tag, String message, Throwable t) {
i(tag, message, t, defaultLifespan);
}
public void w(String tag, String message, Throwable t) {
w(tag, message, t, defaultLifespan);
}
public void e(String tag, String message, Throwable t) {
e(tag, message, t, defaultLifespan);
}
public void v(String tag, String message) {
v(tag, message, null);
}
@ -153,10 +227,6 @@ public final class Log {
public void e(String tag, String message) {
e(tag, message, null);
}
public void wtf(String tag, String message) {
wtf(tag, message, null);
}
}
public interface InternalCheck {

Wyświetl plik

@ -4,23 +4,24 @@ package org.signal.core.util.logging;
* A logger that does nothing.
*/
class NoopLogger extends Log.Logger {
@Override
public void v(String tag, String message, Throwable t) { }
NoopLogger() {
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() { }