Make log stripping more consistent

This commit is contained in:
Ravi Khadiwala authored and ravi-signal committed 2026-07-17 12:40:47 -05:00
1 parent 90a5ad589b
commit 70f83326ef
6 files changed
+10 -9

No files matched your search

@@ -100,7 +100,7 @@ public class CaptchaChecker {
final Set<String> allowedSiteKeys = client.validSiteKeys(parsedAction);
if (!allowedSiteKeys.contains(siteKey)) {
logger.debug("invalid site-key {}, action={}, token={}", siteKey, action, token);
logger.debug("invalid site-key {}, action={}", siteKey, action);
Metrics.counter(INVALID_SITEKEY_COUNTER_NAME, "action", action).increment();
throw new InvalidCaptchaArgumentException("invalid captcha site-key");
}
@@ -164,8 +164,8 @@ public class PushNotificationManager {
result.unregisteredTimestamp());
}
} else {
logger.debug("Failed to deliver {} push notification to {} ({})",
pushNotification.notificationType(), pushNotification.deviceToken(), pushNotification.tokenType(),
logger.debug("Failed to deliver {} push notification to token of type {}",
pushNotification.notificationType(), pushNotification.tokenType(),
throwable);
Metrics.counter(FAILED_NOTIFICATION_COUNTER_NAME, "cause", throwable.getClass().getSimpleName()).increment();
@@ -390,8 +390,8 @@ public class Accounts {
writeItems.add(phoneNumberConstraintPut);
} else {
log.error("Reclaiming account with a non-equivalent phone number. Old account {}:{}:{}, new account {}:{}:{}",
existingAccount.getUuid(), existingAccount.getNumber(), existingAccount.getPhoneNumberIdentifier(),
accountToCreate.getUuid(), accountToCreate.getNumber(), accountToCreate.getPhoneNumberIdentifier());
existingAccount.getUuid(), redactPhoneNumber(existingAccount.getNumber()), existingAccount.getPhoneNumberIdentifier(),
accountToCreate.getUuid(), redactPhoneNumber(accountToCreate.getNumber()), accountToCreate.getPhoneNumberIdentifier());
throw new IllegalArgumentException("reclaimed accounts must have equivalent phone numbers");
}
}
@@ -285,7 +285,6 @@ public class GooglePlayBillingManager implements SubscriptionPaymentProcessor {
.orElse(AcknowledgementState.UNSPECIFIED);
if (acknowledgementState != AcknowledgementState.ACKNOWLEDGED) {
// We should only ever generate receipts for a stored and acknowledged token.
logger.error("Tried to fetch receipt for purchaseToken {} that was never acknowledged", purchaseToken);
throw new IllegalStateException("Tried to fetch receipt for purchaseToken that was never acknowledged");
}
@@ -109,8 +109,9 @@ public final class HeaderUtils {
Tag.of("path", containerRequestContext.getUriInfo().getPath())))
.increment();
logger.debug("Could not get acceptable languages; Accept-Language: {}; User-Agent: {}",
containerRequestContext.getHeaderString(HttpHeaders.ACCEPT_LANGUAGE),
userAgent,
// Strip any control codes to avoid any weird formatting with console loggers
containerRequestContext.getHeaderString(HttpHeaders.ACCEPT_LANGUAGE).replaceAll("\\p{Cntrl}", ""),
userAgent.replaceAll("\\p{Cntrl}", ""),
e);
return List.of();
@@ -57,7 +57,8 @@ public class LoggingUnhandledExceptionMapper extends LoggingExceptionMapper<Thro
super.formatLogMessage(id, exception),
requestMethod,
requestPath,
userAgent) ;
// Strip any control codes to avoid any weird formatting with console loggers
userAgent.replaceAll("\\p{Cntrl}", ""));
}
}