session-ios/Signal/src/util/OWSScrubbingLogFormatter.m
Michael Kirk 6466e9f41f [SSK] Better logging for envelopes
Leave last 3 digits of recipientId when scrubbing logs.

This is in line with other Signal clients, and makes it possible to
trace interactions.

// FREEBIE
2017-03-23 17:10:26 -04:00

29 lines
1,016 B
Objective-C

//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "OWSScrubbingLogFormatter.h"
NS_ASSUME_NONNULL_BEGIN
@implementation OWSScrubbingLogFormatter
- (NSString *)formatLogMessage:(DDLogMessage *)logMessage
{
NSString *string = [super formatLogMessage:logMessage];
NSRegularExpression *phoneRegex =
[NSRegularExpression regularExpressionWithPattern:@"\\+\\d{7,12}(\\d{3})"
options:NSRegularExpressionCaseInsensitive
error:nil];
NSString *filteredString = [phoneRegex stringByReplacingMatchesInString:string
options:0
range:NSMakeRange(0, [string length])
withTemplate:@"[ REDACTED_PHONE_NUMBER:xxx$1 ]"];
return filteredString;
}
@end
NS_ASSUME_NONNULL_END