This commit is contained in:
Niels Andriesse 2021-07-15 16:39:59 +10:00
parent 595080aba2
commit d2161545d6
13 changed files with 0 additions and 319 deletions

View File

@ -559,15 +559,11 @@
C38EF30D255B6DBF007E1867 /* OWSUnreadIndicator.m in Sources */ = {isa = PBXBuildFile; fileRef = C38EF2E3255B6DB9007E1867 /* OWSUnreadIndicator.m */; };
C38EF30E255B6DBF007E1867 /* FullTextSearcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = C38EF2E4255B6DB9007E1867 /* FullTextSearcher.swift */; };
C38EF30F255B6DBF007E1867 /* AppPreferences.swift in Sources */ = {isa = PBXBuildFile; fileRef = C38EF2E5255B6DB9007E1867 /* AppPreferences.swift */; };
C38EF310255B6DBF007E1867 /* DebugLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = C38EF2E6255B6DBA007E1867 /* DebugLogger.m */; };
C38EF311255B6DBF007E1867 /* OWSScrubbingLogFormatter.h in Headers */ = {isa = PBXBuildFile; fileRef = C38EF2E7255B6DBA007E1867 /* OWSScrubbingLogFormatter.h */; settings = {ATTRIBUTES = (Public, ); }; };
C38EF313255B6DBF007E1867 /* OWSUnreadIndicator.h in Headers */ = {isa = PBXBuildFile; fileRef = C38EF2E9255B6DBA007E1867 /* OWSUnreadIndicator.h */; settings = {ATTRIBUTES = (Public, ); }; };
C38EF317255B6DBF007E1867 /* DisplayableText.swift in Sources */ = {isa = PBXBuildFile; fileRef = C38EF2ED255B6DBB007E1867 /* DisplayableText.swift */; };
C38EF31A255B6DBF007E1867 /* OWSAnyTouchGestureRecognizer.m in Sources */ = {isa = PBXBuildFile; fileRef = C38EF2F0255B6DBB007E1867 /* OWSAnyTouchGestureRecognizer.m */; };
C38EF31C255B6DBF007E1867 /* Searcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = C38EF2F2255B6DBC007E1867 /* Searcher.swift */; };
C38EF31D255B6DBF007E1867 /* UIImage+OWS.swift in Sources */ = {isa = PBXBuildFile; fileRef = C38EF2F3255B6DBC007E1867 /* UIImage+OWS.swift */; };
C38EF320255B6DBF007E1867 /* OWSScrubbingLogFormatter.m in Sources */ = {isa = PBXBuildFile; fileRef = C38EF2F6255B6DBC007E1867 /* OWSScrubbingLogFormatter.m */; };
C38EF322255B6DBF007E1867 /* DebugLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = C38EF2F8255B6DBC007E1867 /* DebugLogger.h */; settings = {ATTRIBUTES = (Public, ); }; };
C38EF324255B6DBF007E1867 /* Bench.swift in Sources */ = {isa = PBXBuildFile; fileRef = C38EF2FA255B6DBD007E1867 /* Bench.swift */; };
C38EF326255B6DBF007E1867 /* ConversationStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = C38EF2FC255B6DBD007E1867 /* ConversationStyle.swift */; };
C38EF32A255B6DBF007E1867 /* UIUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = C38EF300255B6DBD007E1867 /* UIUtil.m */; };
@ -1551,8 +1547,6 @@
C38EF2E3255B6DB9007E1867 /* OWSUnreadIndicator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OWSUnreadIndicator.m; path = SignalUtilitiesKit/Messaging/OWSUnreadIndicator.m; sourceTree = SOURCE_ROOT; };
C38EF2E4255B6DB9007E1867 /* FullTextSearcher.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FullTextSearcher.swift; path = SignalUtilitiesKit/Messaging/FullTextSearcher.swift; sourceTree = SOURCE_ROOT; };
C38EF2E5255B6DB9007E1867 /* AppPreferences.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AppPreferences.swift; path = SignalUtilitiesKit/Database/AppPreferences.swift; sourceTree = SOURCE_ROOT; };
C38EF2E6255B6DBA007E1867 /* DebugLogger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DebugLogger.m; path = SignalUtilitiesKit/Utilities/DebugLogger.m; sourceTree = SOURCE_ROOT; };
C38EF2E7255B6DBA007E1867 /* OWSScrubbingLogFormatter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OWSScrubbingLogFormatter.h; path = SignalUtilitiesKit/Utilities/OWSScrubbingLogFormatter.h; sourceTree = SOURCE_ROOT; };
C38EF2E9255B6DBA007E1867 /* OWSUnreadIndicator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OWSUnreadIndicator.h; path = SignalUtilitiesKit/Messaging/OWSUnreadIndicator.h; sourceTree = SOURCE_ROOT; };
C38EF2EC255B6DBA007E1867 /* ProximityMonitoringManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ProximityMonitoringManager.swift; path = SessionMessagingKit/Utilities/ProximityMonitoringManager.swift; sourceTree = SOURCE_ROOT; };
C38EF2ED255B6DBB007E1867 /* DisplayableText.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = DisplayableText.swift; path = SignalUtilitiesKit/Utilities/DisplayableText.swift; sourceTree = SOURCE_ROOT; };
@ -1562,9 +1556,7 @@
C38EF2F2255B6DBC007E1867 /* Searcher.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Searcher.swift; path = SignalUtilitiesKit/Utilities/Searcher.swift; sourceTree = SOURCE_ROOT; };
C38EF2F3255B6DBC007E1867 /* UIImage+OWS.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "UIImage+OWS.swift"; path = "SignalUtilitiesKit/Utilities/UIImage+OWS.swift"; sourceTree = SOURCE_ROOT; };
C38EF2F5255B6DBC007E1867 /* OWSAudioPlayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OWSAudioPlayer.h; path = SessionMessagingKit/Utilities/OWSAudioPlayer.h; sourceTree = SOURCE_ROOT; };
C38EF2F6255B6DBC007E1867 /* OWSScrubbingLogFormatter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OWSScrubbingLogFormatter.m; path = SignalUtilitiesKit/Utilities/OWSScrubbingLogFormatter.m; sourceTree = SOURCE_ROOT; };
C38EF2F7255B6DBC007E1867 /* OWSAudioPlayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OWSAudioPlayer.m; path = SessionMessagingKit/Utilities/OWSAudioPlayer.m; sourceTree = SOURCE_ROOT; };
C38EF2F8255B6DBC007E1867 /* DebugLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DebugLogger.h; path = SignalUtilitiesKit/Utilities/DebugLogger.h; sourceTree = SOURCE_ROOT; };
C38EF2FA255B6DBD007E1867 /* Bench.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Bench.swift; path = SignalUtilitiesKit/Utilities/Bench.swift; sourceTree = SOURCE_ROOT; };
C38EF2FB255B6DBD007E1867 /* OWSWindowManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OWSWindowManager.h; path = SessionMessagingKit/Utilities/OWSWindowManager.h; sourceTree = SOURCE_ROOT; };
C38EF2FC255B6DBD007E1867 /* ConversationStyle.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ConversationStyle.swift; path = SignalUtilitiesKit/Messaging/ConversationStyle.swift; sourceTree = SOURCE_ROOT; };
@ -3359,11 +3351,7 @@
C33FDAE0255A580400E217F9 /* ByteParser.m */,
C38EF3DD255B6DF1007E1867 /* UIAlertController+OWS.swift */,
C38EF241255B6D67007E1867 /* Collection+OWS.swift */,
C38EF2F8255B6DBC007E1867 /* DebugLogger.h */,
C38EF2E6255B6DBA007E1867 /* DebugLogger.m */,
C38EF3AE255B6DE5007E1867 /* OrderedDictionary.swift */,
C38EF2E7255B6DBA007E1867 /* OWSScrubbingLogFormatter.h */,
C38EF2F6255B6DBC007E1867 /* OWSScrubbingLogFormatter.m */,
C38EF301255B6DBD007E1867 /* OWSFormat.h */,
C38EF305255B6DBE007E1867 /* OWSFormat.m */,
C38EF226255B6D5D007E1867 /* ShareViewDelegate.swift */,
@ -3547,7 +3535,6 @@
C33FDD74255A582000E217F9 /* OWSPrimaryStorage+keyFromIntLong.h in Headers */,
C33FDDB0255A582000E217F9 /* NSURLSessionDataTask+StatusCode.h in Headers */,
C33FDDD0255A582000E217F9 /* FunctionalUtil.h in Headers */,
C38EF311255B6DBF007E1867 /* OWSScrubbingLogFormatter.h in Headers */,
B8C2B3442563782400551B4D /* ThreadUtil.h in Headers */,
C38EF334255B6DBF007E1867 /* UIUtil.h in Headers */,
C33FDD5B255A582000E217F9 /* OWSOperation.h in Headers */,
@ -3586,7 +3573,6 @@
C37F5396255B95BD002AEA92 /* OWSAnyTouchGestureRecognizer.h in Headers */,
C38EF404255B6DF7007E1867 /* ContactTableViewCell.h in Headers */,
C33FDDB2255A582000E217F9 /* NSArray+OWS.h in Headers */,
C38EF322255B6DBF007E1867 /* DebugLogger.h in Headers */,
C38EF2D7255B6DAF007E1867 /* OWSProfileManager.h in Headers */,
C38EF290255B6D86007E1867 /* AppSetup.h in Headers */,
C37F5385255B94F6002AEA92 /* SelectRecipientViewController.h in Headers */,
@ -4415,7 +4401,6 @@
C33FDD49255A582000E217F9 /* ParamParser.swift in Sources */,
C38EF35F255B6DCC007E1867 /* SelectRecipientViewController.m in Sources */,
C38EF3C5255B6DE7007E1867 /* OWSViewController+ImageEditor.swift in Sources */,
C38EF320255B6DBF007E1867 /* OWSScrubbingLogFormatter.m in Sources */,
C38EF39B255B6DDA007E1867 /* ThreadViewModel.swift in Sources */,
C38EF2A5255B6D93007E1867 /* Identicon+ObjC.swift in Sources */,
C38EF273255B6D7A007E1867 /* OWSDatabaseMigrationRunner.m in Sources */,
@ -4479,7 +4464,6 @@
C33FDD13255A582000E217F9 /* OWSFailedAttachmentDownloadsJob.m in Sources */,
C38EF24D255B6D67007E1867 /* UIView+OWS.swift in Sources */,
C38EF408255B6DF7007E1867 /* OWSSearchBar.m in Sources */,
C38EF310255B6DBF007E1867 /* DebugLogger.m in Sources */,
C38EF38B255B6DD2007E1867 /* AttachmentPrepViewController.swift in Sources */,
C33FDC7B255A582000E217F9 /* NSSet+Functional.m in Sources */,
C38EF405255B6DF7007E1867 /* OWSButton.swift in Sources */,

View File

@ -3,7 +3,6 @@
//
#import "AppDelegate.h"
#import "DebugLogger.h"
#import "MainAppContext.h"
#import "OWSBackup.h"
#import "OWSOrphanDataCleaner.h"
@ -155,19 +154,6 @@ static NSTimeInterval launchStartedAt;
// need to tell NSKeyedUnarchiver about the changes.
[NSKeyedUnarchiver setClass:OWSLinkPreview.class forClassName:@"SessionServiceKit.OWSLinkPreview"];
BOOL isLoggingEnabled;
#ifdef DEBUG
// Specified at Product -> Scheme -> Edit Scheme -> Test -> Arguments -> Environment to avoid things like
// the phone directory being looked up during tests.
isLoggingEnabled = TRUE;
[DebugLogger.sharedLogger enableTTYLogging];
#elif RELEASE
isLoggingEnabled = OWSPreferences.isLoggingEnabled;
#endif
if (isLoggingEnabled) {
[DebugLogger.sharedLogger enableFileLogging];
}
[Cryptography seedRandom];
// XXX - careful when moving this. It must happen before we initialize OWSPrimaryStorage.

View File

@ -8,7 +8,6 @@
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
@import CocoaLumberjack;
#ifdef DEBUG
static const NSUInteger ddLogLevel = DDLogLevelAll;
#else

View File

@ -6,7 +6,6 @@
#import "AppDelegate.h"
#import "Session-Swift.h"
#import <SignalCoreKit/Threading.h>
#import <SignalUtilitiesKit/DebugLogger.h>
#import <SessionMessagingKit/Environment.h>
#import <SessionMessagingKit/OWSPrimaryStorage.h>
#import <SessionMessagingKit/TSContactThread.h>

View File

@ -102,11 +102,6 @@ public final class NotificationServiceExtension : UNNotificationServiceExtension
// This should be the first thing we do.
SetCurrentAppContext(NotificationServiceExtensionContext())
DebugLogger.shared().enableTTYLogging()
if _isDebugAssertConfiguration() {
DebugLogger.shared().enableFileLogging()
}
_ = AppVersion.sharedInstance()
Cryptography.seedRandom()

View File

@ -8,13 +8,6 @@
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
@import CocoaLumberjack;
#ifdef DEBUG
static const NSUInteger ddLogLevel = DDLogLevelAll;
#else
static const NSUInteger ddLogLevel = DDLogLevelInfo;
#endif
#import <SignalCoreKit/OWSAsserts.h>
#import <SignalCoreKit/NSObject+OWS.h>
#import <SessionUIKit/SessionUIKit.h>

View File

@ -11,7 +11,6 @@
#import <SignalCoreKit/NSObject+OWS.h>
#import <SignalCoreKit/OWSAsserts.h>
#import <SignalCoreKit/OWSLogs.h>
#import <SignalUtilitiesKit/DebugLogger.h>
#import <SessionMessagingKit/Environment.h>
#import <SessionMessagingKit/OWSPreferences.h>
#import <SignalUtilitiesKit/UIColor+OWS.h>

View File

@ -24,13 +24,6 @@ final class ShareVC : UINavigationController, ShareViewDelegate, AppModeManagerD
AppModeManager.configure(delegate: self)
DebugLogger.shared().enableTTYLogging()
if _isDebugAssertConfiguration() {
DebugLogger.shared().enableFileLogging()
} else if OWSPreferences.isLoggingEnabled() {
DebugLogger.shared().enableFileLogging()
}
Logger.info("")
_ = AppVersion.sharedInstance()

View File

@ -14,7 +14,6 @@ FOUNDATION_EXPORT const unsigned char SignalUtilitiesKitVersionString[];
#import <SignalUtilitiesKit/ByteParser.h>
#import <SignalUtilitiesKit/ContactCellView.h>
#import <SignalUtilitiesKit/ContactTableViewCell.h>
#import <SignalUtilitiesKit/DebugLogger.h>
#import <SignalUtilitiesKit/FunctionalUtil.h>
#import <SignalUtilitiesKit/NSArray+OWS.h>
#import <SignalUtilitiesKit/NSAttributedString+OWS.h>
@ -37,7 +36,6 @@ FOUNDATION_EXPORT const unsigned char SignalUtilitiesKitVersionString[];
#import <SignalUtilitiesKit/OWSProfileManager.h>
#import <SignalUtilitiesKit/OWSQueues.h>
#import <SignalUtilitiesKit/OWSResaveCollectionDBMigration.h>
#import <SignalUtilitiesKit/OWSScrubbingLogFormatter.h>
#import <SignalUtilitiesKit/OWSSearchBar.h>
#import <SignalUtilitiesKit/OWSTableViewController.h>
#import <SignalUtilitiesKit/OWSTextField.h>

View File

@ -1,25 +0,0 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import <CocoaLumberjack/DDFileLogger.h>
NS_ASSUME_NONNULL_BEGIN
@interface DebugLogger : NSObject
+ (instancetype)sharedLogger;
- (void)enableFileLogging;
- (void)disableFileLogging;
- (void)enableTTYLogging;
- (void)wipeLogs;
- (NSArray<NSString *> *)allLogFilePaths;
@end
NS_ASSUME_NONNULL_END

View File

@ -1,138 +0,0 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "DebugLogger.h"
#import "OWSScrubbingLogFormatter.h"
#import <SessionUtilitiesKit/AppContext.h>
#import <SessionUtilitiesKit/OWSFileSystem.h>
#pragma mark Logging - Production logging wants us to write some logs to a file in case we need it for debugging.
#import <CocoaLumberjack/DDTTYLogger.h>
NS_ASSUME_NONNULL_BEGIN
const NSUInteger kMaxDebugLogFileSize = 1024 * 1024 * 3;
@interface DebugLogger ()
@property (nonatomic, nullable) DDFileLogger *fileLogger;
@end
#pragma mark -
@implementation DebugLogger
+ (instancetype)sharedLogger
{
static DebugLogger *sharedManager = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedManager = [self new];
});
return sharedManager;
}
+ (NSString *)mainAppLogsDirPath
{
NSString *dirPath = [[OWSFileSystem cachesDirectoryPath] stringByAppendingPathComponent:@"Logs"];
[OWSFileSystem ensureDirectoryExists:dirPath];
return dirPath;
}
+ (NSString *)shareExtensionLogsDirPath
{
NSString *dirPath =
[[OWSFileSystem appSharedDataDirectoryPath] stringByAppendingPathComponent:@"ShareExtensionLogs"];
[OWSFileSystem ensureDirectoryExists:dirPath];
return dirPath;
}
- (NSString *)logsDirPath
{
// This assumes that the only app extension is the share app extension.
return (CurrentAppContext().isMainApp ? DebugLogger.mainAppLogsDirPath : DebugLogger.shareExtensionLogsDirPath);
}
- (void)enableFileLogging
{
NSString *logsDirPath = [self logsDirPath];
// Logging to file, because it's in the Cache folder, they are not uploaded in iTunes/iCloud backups.
id<DDLogFileManager> logFileManager =
[[DDLogFileManagerDefault alloc] initWithLogsDirectory:logsDirPath defaultFileProtectionLevel:@""];
self.fileLogger = [[DDFileLogger alloc] initWithLogFileManager:logFileManager];
// 24 hour rolling.
self.fileLogger.rollingFrequency = kDayInterval;
// Keep last 3 days of logs - or last 3 logs (if logs rollover due to max file size).
self.fileLogger.logFileManager.maximumNumberOfLogFiles = 3;
self.fileLogger.maximumFileSize = kMaxDebugLogFileSize;
self.fileLogger.logFormatter = [OWSScrubbingLogFormatter new];
[DDLog addLogger:self.fileLogger];
}
- (void)disableFileLogging
{
[DDLog removeLogger:self.fileLogger];
self.fileLogger = nil;
}
- (void)enableTTYLogging
{
[DDLog addLogger:DDTTYLogger.sharedInstance];
}
- (NSArray<NSString *> *)allLogFilePaths
{
NSFileManager *fileManager = [NSFileManager defaultManager];
NSMutableSet<NSString *> *logPathSet = [NSMutableSet new];
for (NSString *logDirPath in @[
DebugLogger.mainAppLogsDirPath,
DebugLogger.shareExtensionLogsDirPath,
]) {
NSError *error;
for (NSString *filename in [fileManager contentsOfDirectoryAtPath:logDirPath error:&error]) {
NSString *logPath = [logDirPath stringByAppendingPathComponent:filename];
[logPathSet addObject:logPath];
}
if (error) {
OWSFailDebug(@"Failed to find log files: %@", error);
}
}
// To be extra conservative, also add all logs from log file manager.
// This should be redundant with the logic above.
[logPathSet addObjectsFromArray:self.fileLogger.logFileManager.unsortedLogFilePaths];
NSArray<NSString *> *logPaths = logPathSet.allObjects;
return [logPaths sortedArrayUsingSelector:@selector((compare:))];
}
- (void)wipeLogs
{
NSArray<NSString *> *logFilePaths = self.allLogFilePaths;
BOOL reenableLogging = (self.fileLogger ? YES : NO);
if (reenableLogging) {
[self disableFileLogging];
}
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error;
for (NSString *logFilePath in logFilePaths) {
BOOL success = [fileManager removeItemAtPath:logFilePath error:&error];
if (!success || error) {
OWSFailDebug(@"Failed to delete log file: %@", error);
}
}
if (reenableLogging) {
[self enableFileLogging];
}
}
@end
NS_ASSUME_NONNULL_END

View File

@ -1,11 +0,0 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
NS_ASSUME_NONNULL_BEGIN
@interface OWSScrubbingLogFormatter : DDLogFileFormatterDefault
@end
NS_ASSUME_NONNULL_END

View File

@ -1,91 +0,0 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "OWSScrubbingLogFormatter.h"
NS_ASSUME_NONNULL_BEGIN
@implementation OWSScrubbingLogFormatter
- (NSRegularExpression *)phoneRegex
{
static NSRegularExpression *regex = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
NSError *error;
regex = [NSRegularExpression regularExpressionWithPattern:@"\\+\\d{7,12}(\\d{3})"
options:NSRegularExpressionCaseInsensitive
error:&error];
if (error || !regex) {
OWSFail(@"could not compile regular expression: %@", error);
}
});
return regex;
}
- (NSRegularExpression *)dataRegex
{
static NSRegularExpression *regex = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
NSError *error;
regex = [NSRegularExpression regularExpressionWithPattern:@"<([\\da-f]{2})[\\da-f]{6}( [\\da-f]{8})*>"
options:NSRegularExpressionCaseInsensitive
error:&error];
if (error || !regex) {
OWSFail(@"could not compile regular expression: %@", error);
}
});
return regex;
}
- (NSRegularExpression *)ipV4AddressRegex
{
static NSRegularExpression *regex = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
// NOTE: The group matches the last quad of the IPv4 address.
NSError *error;
regex = [NSRegularExpression regularExpressionWithPattern:@"\\d+\\.\\d+\\.\\d+\\.(\\d+)"
options:NSRegularExpressionCaseInsensitive
error:&error];
if (error || !regex) {
OWSFail(@"could not compile regular expression: %@", error);
}
});
return regex;
}
- (NSString *__nullable)formatLogMessage:(DDLogMessage *)logMessage
{
NSString *logString = [super formatLogMessage:logMessage];
NSRegularExpression *phoneRegex = self.phoneRegex;
logString = [phoneRegex stringByReplacingMatchesInString:logString
options:0
range:NSMakeRange(0, [logString length])
withTemplate:@"[ REDACTED_PHONE_NUMBER:xxx$1 ]"];
// We capture only the first two characters of the hex string for logging.
// example log line: "Called someFunction with nsData: <01234567 89abcdef>"
// scrubbed output: "Called someFunction with nsData: [ REDACTED_DATA:01 ]"
NSRegularExpression *dataRegex = self.dataRegex;
logString = [dataRegex stringByReplacingMatchesInString:logString
options:0
range:NSMakeRange(0, [logString length])
withTemplate:@"[ REDACTED_DATA:$1... ]"];
NSRegularExpression *ipV4AddressRegex = self.ipV4AddressRegex;
logString = [ipV4AddressRegex stringByReplacingMatchesInString:logString
options:0
range:NSMakeRange(0, [logString length])
withTemplate:@"[ REDACTED_IPV4_ADDRESS:...$1 ]"];
return logString;
}
@end
NS_ASSUME_NONNULL_END