Log call session description.

pull/1/head
Matthew Chen 7 years ago
parent 2d06c05a4f
commit b4539328e1

@ -10,9 +10,9 @@ NS_ASSUME_NONNULL_BEGIN
- (NSRegularExpression *)phoneRegex - (NSRegularExpression *)phoneRegex
{ {
NSString *key = @"OWSScrubbingLogFormatter.phoneRegex"; static NSRegularExpression *regex = nil;
NSRegularExpression *_Nullable regex = NSThread.currentThread.threadDictionary[key]; static dispatch_once_t onceToken;
if (!regex) { dispatch_once(&onceToken, ^{
NSError *error; NSError *error;
regex = [NSRegularExpression regularExpressionWithPattern:@"\\+\\d{7,12}(\\d{3})" regex = [NSRegularExpression regularExpressionWithPattern:@"\\+\\d{7,12}(\\d{3})"
options:NSRegularExpressionCaseInsensitive options:NSRegularExpressionCaseInsensitive
@ -20,16 +20,15 @@ NS_ASSUME_NONNULL_BEGIN
if (error || !regex) { if (error || !regex) {
OWSFail(@"%@ could not compile regular expression: %@", self.logTag, error); OWSFail(@"%@ could not compile regular expression: %@", self.logTag, error);
} }
NSThread.currentThread.threadDictionary[key] = regex; });
}
return regex; return regex;
} }
- (NSRegularExpression *)dataRegex - (NSRegularExpression *)dataRegex
{ {
NSString *key = @"OWSScrubbingLogFormatter.dataRegex"; static NSRegularExpression *regex = nil;
NSRegularExpression *_Nullable regex = NSThread.currentThread.threadDictionary[key]; static dispatch_once_t onceToken;
if (!regex) { dispatch_once(&onceToken, ^{
NSError *error; NSError *error;
regex = [NSRegularExpression regularExpressionWithPattern:@"<([\\da-f]{2})[\\da-f]{6}( [\\da-f]{8})*>" regex = [NSRegularExpression regularExpressionWithPattern:@"<([\\da-f]{2})[\\da-f]{6}( [\\da-f]{8})*>"
options:NSRegularExpressionCaseInsensitive options:NSRegularExpressionCaseInsensitive
@ -37,16 +36,15 @@ NS_ASSUME_NONNULL_BEGIN
if (error || !regex) { if (error || !regex) {
OWSFail(@"%@ could not compile regular expression: %@", self.logTag, error); OWSFail(@"%@ could not compile regular expression: %@", self.logTag, error);
} }
NSThread.currentThread.threadDictionary[key] = regex; });
}
return regex; return regex;
} }
- (NSRegularExpression *)ipAddressRegex - (NSRegularExpression *)ipAddressRegex
{ {
NSString *key = @"OWSScrubbingLogFormatter.ipAddressRegex"; static NSRegularExpression *regex = nil;
NSRegularExpression *_Nullable regex = NSThread.currentThread.threadDictionary[key]; static dispatch_once_t onceToken;
if (!regex) { dispatch_once(&onceToken, ^{
// Match IPv4 and IPv6 addresses. // Match IPv4 and IPv6 addresses.
// //
// NOTE: the second group matches the last "quad/hex?" of the IPv4/IPv6 address. // NOTE: the second group matches the last "quad/hex?" of the IPv4/IPv6 address.
@ -57,8 +55,7 @@ NS_ASSUME_NONNULL_BEGIN
if (error || !regex) { if (error || !regex) {
OWSFail(@"%@ could not compile regular expression: %@", self.logTag, error); OWSFail(@"%@ could not compile regular expression: %@", self.logTag, error);
} }
NSThread.currentThread.threadDictionary[key] = regex; });
}
return regex; return regex;
} }

Loading…
Cancel
Save