Improve logging in RetrieveProfileJob.
parent
f832a36a5e
commit
b38d02061d
|
@ -22,6 +22,6 @@ public class JobLogger {
|
|||
: String.valueOf(job.getParameters().getLifespan()) + " ms";
|
||||
return String.format(Locale.US,
|
||||
"[%s][%s]%s %s (Time Since Submission: %d ms, Lifespan: %s, Run Attempt: %d/%s)",
|
||||
id, job.getClass().getSimpleName(), tag, event, timeSinceSubmission, lifespan, runAttempt, maxAttempts);
|
||||
"JOB::" + id, job.getClass().getSimpleName(), tag, event, timeSinceSubmission, lifespan, runAttempt, maxAttempts);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,6 @@ public final class ConstraintSpec {
|
|||
|
||||
@Override
|
||||
public @NonNull String toString() {
|
||||
return String.format("jobSpecId: %s | factoryKey: %s", jobSpecId, factoryKey);
|
||||
return String.format("jobSpecId: JOB::%s | factoryKey: %s", jobSpecId, factoryKey);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,6 @@ public final class DependencySpec {
|
|||
|
||||
@Override
|
||||
public @NonNull String toString() {
|
||||
return String.format("jobSpecId: %s | dependsOnJobSpecId: %s", jobId, dependsOnJobId);
|
||||
return String.format("jobSpecId: JOB::%s | dependsOnJobSpecId: JOB::%s", jobId, dependsOnJobId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ public final class JobSpec {
|
|||
@SuppressLint("DefaultLocale")
|
||||
@Override
|
||||
public @NonNull String toString() {
|
||||
return String.format("id: %s | factoryKey: %s | queueKey: %s | createTime: %d | nextRunAttemptTime: %d | runAttempt: %d | maxAttempts: %d | maxBackoff: %d | maxInstances: %d | lifespan: %d | isRunning: %b | data: %s",
|
||||
return String.format("id: JOB::%s | factoryKey: %s | queueKey: %s | createTime: %d | nextRunAttemptTime: %d | runAttempt: %d | maxAttempts: %d | maxBackoff: %d | maxInstances: %d | lifespan: %d | isRunning: %b | data: %s",
|
||||
id, factoryKey, queueKey, createTime, nextRunAttemptTime, runAttempt, maxAttempts, maxBackoff, maxInstances, lifespan, isRunning, serializedData);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ public class RetrieveProfileJob extends BaseJob {
|
|||
SignalServiceProfile profile = ProfileUtil.retrieveProfile(context, recipient);
|
||||
|
||||
if (recipient.getProfileKey() == null) {
|
||||
Log.i(TAG, "No profile key for available for " + recipient.getId());
|
||||
Log.i(TAG, "No profile key available for " + recipient.getId());
|
||||
} else {
|
||||
Log.i(TAG, "Profile key available for " + recipient.getId());
|
||||
}
|
||||
|
@ -192,8 +192,13 @@ public class RetrieveProfileJob extends BaseJob {
|
|||
String plaintextProfileName = ProfileUtil.decryptName(profileKey, profileName);
|
||||
|
||||
if (!Util.equals(plaintextProfileName, recipient.getProfileName())) {
|
||||
Log.i(TAG, "Profile name updated. Writing new value.");
|
||||
DatabaseFactory.getRecipientDatabase(context).setProfileName(recipient.getId(), plaintextProfileName);
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(plaintextProfileName)) {
|
||||
Log.i(TAG, "No profile name set.");
|
||||
}
|
||||
} catch (InvalidCiphertextException | IOException e) {
|
||||
Log.w(TAG, e);
|
||||
}
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
package org.thoughtcrime.securesms.logsubmit.util;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
|
@ -50,11 +52,18 @@ public final class Scrubber {
|
|||
private static final Pattern GROUP_ID_PATTERN = Pattern.compile("(__)(textsecure_group__![^\\s]+)([^\\s]{2})");
|
||||
private static final String GROUP_ID_CENSOR = "...group...";
|
||||
|
||||
/**
|
||||
* The middle group will be censored.
|
||||
*/
|
||||
private static final Pattern UUID_PATTERN = Pattern.compile("(JOB::)?([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{10})([0-9a-f]{2})", Pattern.CASE_INSENSITIVE);
|
||||
private static final String UUID_CENSOR = "********-****-****-****-**********";
|
||||
|
||||
public static CharSequence scrub(@NonNull CharSequence in) {
|
||||
|
||||
in = scrubE164(in);
|
||||
in = scrubEmail(in);
|
||||
in = scrubGroups(in);
|
||||
in = scrubUuids(in);
|
||||
|
||||
return in;
|
||||
}
|
||||
|
@ -82,6 +91,21 @@ public final class Scrubber {
|
|||
.append(matcher.group(3)));
|
||||
}
|
||||
|
||||
private static CharSequence scrubUuids(@NonNull CharSequence in) {
|
||||
return scrub(in,
|
||||
UUID_PATTERN,
|
||||
(matcher, output) -> {
|
||||
if (matcher.group(1) != null && !matcher.group(1).isEmpty()) {
|
||||
output.append(matcher.group(1))
|
||||
.append(matcher.group(2))
|
||||
.append(matcher.group(3));
|
||||
} else {
|
||||
output.append(UUID_CENSOR)
|
||||
.append(matcher.group(3));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static CharSequence scrub(@NonNull CharSequence in, @NonNull Pattern pattern, @NonNull ProcessMatch processMatch) {
|
||||
final StringBuilder output = new StringBuilder(in.length());
|
||||
final Matcher matcher = pattern.matcher(in);
|
||||
|
|
|
@ -64,8 +64,17 @@ public final class ScrubberTest {
|
|||
{ "A group id __textsecure_group__!abcdefg0987654321 surrounded with text",
|
||||
"A group id __...group...21 surrounded with text" },
|
||||
|
||||
{ "All patterns in a row __textsecure_group__!abcdefg1234567890 +1234567890123456 abc@def.com with text after",
|
||||
"All patterns in a row __...group...90 +*************456 a...@... with text after"
|
||||
{ "a37cb654-c9e0-4c1e-93df-3d11ca3c97f4",
|
||||
"********-****-****-****-**********f4" },
|
||||
|
||||
{ "A UUID a37cb654-c9e0-4c1e-93df-3d11ca3c97f4 surrounded with text",
|
||||
"A UUID ********-****-****-****-**********f4 surrounded with text" },
|
||||
|
||||
{ "JOB::a37cb654-c9e0-4c1e-93df-3d11ca3c97f4",
|
||||
"JOB::a37cb654-c9e0-4c1e-93df-3d11ca3c97f4" },
|
||||
|
||||
{ "All patterns in a row __textsecure_group__!abcdefg1234567890 +1234567890123456 abc@def.com a37cb654-c9e0-4c1e-93df-3d11ca3c97f4 with text after",
|
||||
"All patterns in a row __...group...90 +*************456 a...@... ********-****-****-****-**********f4 with text after"
|
||||
}
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue