Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Tabs changed to spaces in Lumberjack and Xcode directories

  • Loading branch information...
commit e5cc56ea7f50d020021b4562a2aa4b475e2c0091 1 parent d253bd7
@dvor dvor authored
Showing with 16,522 additions and 16,522 deletions.
  1. +1 −1  Lumberjack/DDASLLogger.h
  2. +48 −48 Lumberjack/DDASLLogger.m
  3. +12 −12 Lumberjack/DDAbstractDatabaseLogger.h
  4. +543 −543 Lumberjack/DDAbstractDatabaseLogger.m
  5. +21 −21 Lumberjack/DDFileLogger.h
  6. +850 −850 Lumberjack/DDFileLogger.m
  7. +22 −22 Lumberjack/DDLog.h
  8. +708 −708 Lumberjack/DDLog.m
  9. +14 −14 Lumberjack/DDTTYLogger.h
  10. +1,246 −1,246 Lumberjack/DDTTYLogger.m
  11. +63 −63 Lumberjack/Extensions/DDContextFilterLogFormatter.m
  12. +2 −2 Lumberjack/Extensions/DDDispatchQueueLogFormatter.h
  13. +184 −184 Lumberjack/Extensions/DDDispatchQueueLogFormatter.m
  14. +2 −2 Xcode/BenchmarkIPhone/Classes/BenchmarkIPhoneAppDelegate.h
  15. +2 −2 Xcode/BenchmarkIPhone/Classes/BenchmarkIPhoneAppDelegate.m
  16. +1 −1  Xcode/BenchmarkIPhone/Classes/BenchmarkIPhoneViewController.h
  17. +5 −5 Xcode/BenchmarkIPhone/Classes/BenchmarkIPhoneViewController.m
  18. +1 −1  Xcode/BenchmarkMac/BenchmarkMac/AppDelegate.m
  19. +1 −1  Xcode/BenchmarkMac/BenchmarkMac/main.m
  20. +43 −43 Xcode/ContextFilter/ContextFilterAppDelegate.m
  21. +11 −11 Xcode/ContextFilter/MyContextFilter.m
  22. +2 −2 Xcode/ContextFilter/ThirdPartyFramework.m
  23. +6 −6 Xcode/CoreDataLogger/CoreDataLogger/CoreDataLogger.h
  24. +223 −223 Xcode/CoreDataLogger/CoreDataLogger/CoreDataLogger.m
  25. +2 −2 Xcode/CoreDataLogger/CoreDataLogger/CoreDataLoggerAppDelegate.h
  26. +27 −27 Xcode/CoreDataLogger/CoreDataLogger/CoreDataLoggerAppDelegate.m
  27. +1 −1  Xcode/CoreDataLogger/CoreDataLogger/main.m
  28. +16 −16 Xcode/CustomFormatters/CustomFormattersAppDelegate.m
  29. +2 −2 Xcode/CustomFormatters/TestFormatter.m
  30. +8 −8 Xcode/CustomLogLevels/CustomLogLevelsAppDelegate.m
  31. +60 −60 Xcode/DispatchQueueLogger/DispatchQueueLogger/AppDelegate.m
  32. +1 −1  Xcode/DispatchQueueLogger/DispatchQueueLogger/main.m
  33. +4 −4 Xcode/FineGrainedLogging/FineGrainedLoggingAppDelegate.h
  34. +5 −5 Xcode/FineGrainedLogging/FineGrainedLoggingAppDelegate.m
  35. +2 −2 Xcode/FineGrainedLogging/TimerOne.h
  36. +25 −25 Xcode/FineGrainedLogging/TimerOne.m
  37. +2 −2 Xcode/FineGrainedLogging/TimerTwo.h
  38. +25 −25 Xcode/FineGrainedLogging/TimerTwo.m
  39. +16 −16 Xcode/GlobalLogLevel/GlobalLogLevelAppDelegate.m
  40. +4 −4 Xcode/GlobalLogLevel/Stuff.m
  41. +2 −2 Xcode/LogFileCompressor/CompressingLogFileManager.h
  42. +378 −378 Xcode/LogFileCompressor/CompressingLogFileManager.m
  43. +3 −3 Xcode/LogFileCompressor/LogFileCompressorAppDelegate.h
  44. +19 −19 Xcode/LogFileCompressor/LogFileCompressorAppDelegate.m
  45. +6 −6 Xcode/LumberjackFramework/Desktop/FmwkTest/AppDelegate.m
  46. +1 −1  Xcode/LumberjackFramework/Desktop/FmwkTest/main.m
  47. +10 −10 Xcode/LumberjackFramework/Mobile/LibTest/AppDelegate.m
  48. +3 −3 Xcode/LumberjackFramework/Mobile/LibTest/main.m
  49. +52 −52 Xcode/OverflowTestMac/OverflowTestMacAppDelegate.m
  50. +1 −1  Xcode/OverflowTestMac/SlowLogger.m
  51. +5 −5 Xcode/PerUserLogLevels/PerUserLogLevels/AppDelegate.m
  52. +1 −1  Xcode/PerUserLogLevels/PerUserLogLevels/main.m
  53. +3 −3 Xcode/RollingTestMac/RollingTestMacAppDelegate.h
  54. +39 −39 Xcode/RollingTestMac/RollingTestMacAppDelegate.m
  55. +3 −3 Xcode/SQLiteLogger/FMDB/FMDatabase.h
  56. +57 −57 Xcode/SQLiteLogger/FMDB/FMDatabase.m
  57. +4 −4 Xcode/SQLiteLogger/FMDBLogger.h
  58. +188 −188 Xcode/SQLiteLogger/FMDBLogger.m
  59. +2 −2 Xcode/SQLiteLogger/SQLiteLogger/SQLiteLoggerAppDelegate.h
  60. +27 −27 Xcode/SQLiteLogger/SQLiteLogger/SQLiteLoggerAppDelegate.m
  61. +1 −1  Xcode/SQLiteLogger/SQLiteLogger/main.m
  62. +4 −4 Xcode/Testing/NonArcTest/NonArcTest/AppDelegate.m
  63. +1 −1  Xcode/Testing/NonArcTest/NonArcTest/main.m
  64. +6 −6 Xcode/Testing/RegisteredDynamicLogging/Desktop/RegisteredLoggingTest/Lions.m
  65. +1 −1  Xcode/Testing/RegisteredDynamicLogging/Desktop/RegisteredLoggingTest/RegisteredLoggingTestAppDelegate.h
  66. +16 −16 Xcode/Testing/RegisteredDynamicLogging/Desktop/RegisteredLoggingTest/RegisteredLoggingTestAppDelegate.m
  67. +6 −6 Xcode/Testing/RegisteredDynamicLogging/Desktop/RegisteredLoggingTest/Tigers.m
  68. +1 −1  Xcode/Testing/RegisteredDynamicLogging/Desktop/RegisteredLoggingTest/main.m
  69. +6 −6 Xcode/Testing/RegisteredDynamicLogging/Mobile/RegisteredLoggingTest/Lions.m
  70. +19 −19 Xcode/Testing/RegisteredDynamicLogging/Mobile/RegisteredLoggingTest/RegisteredLoggingTestAppDelegate.m
  71. +6 −6 Xcode/Testing/RegisteredDynamicLogging/Mobile/RegisteredLoggingTest/Tigers.m
  72. +4 −4 Xcode/Testing/RegisteredDynamicLogging/Mobile/RegisteredLoggingTest/main.m
  73. +45 −45 Xcode/Testing/TestXcodeColors/Desktop/TestXcodeColors/AppDelegate.m
  74. +1 −1  Xcode/Testing/TestXcodeColors/Desktop/TestXcodeColors/main.m
  75. +72 −72 Xcode/Testing/TestXcodeColors/Mobile/TextXcodeColors/AppDelegate.m
  76. +1 −1  Xcode/Testing/TestXcodeColors/Mobile/TextXcodeColors/ViewController.h
  77. +3 −3 Xcode/Testing/TestXcodeColors/Mobile/TextXcodeColors/main.m
  78. +9 −9 Xcode/UniversalApp/Classes/UniversalAppAppDelegate.m
  79. +5 −5 Xcode/UniversalApp/Classes/UniversalAppViewController.m
  80. +150 −150 Xcode/WebServerIPhone/Classes/MyHTTPConnection.m
  81. +6 −6 Xcode/WebServerIPhone/Classes/WebServerIPhoneAppDelegate.h
  82. +84 −84 Xcode/WebServerIPhone/Classes/WebServerIPhoneAppDelegate.m
  83. +3 −3 Xcode/WebServerIPhone/Classes/WebSocketLogger.h
  84. +62 −62 Xcode/WebServerIPhone/Classes/WebSocketLogger.m
  85. +12 −12 Xcode/WebServerIPhone/Vendor/CocoaAsyncSocket/GCDAsyncSocket.h
  86. +6,013 −6,013 Xcode/WebServerIPhone/Vendor/CocoaAsyncSocket/GCDAsyncSocket.m
  87. +113 −113 Xcode/WebServerIPhone/Vendor/CocoaHTTPServer/Categories/DDData.m
  88. +66 −66 Xcode/WebServerIPhone/Vendor/CocoaHTTPServer/Categories/DDNumber.m
  89. +66 −66 Xcode/WebServerIPhone/Vendor/CocoaHTTPServer/Categories/DDRange.m
  90. +13 −13 Xcode/WebServerIPhone/Vendor/CocoaHTTPServer/HTTPAuthenticationRequest.h
  91. +109 −109 Xcode/WebServerIPhone/Vendor/CocoaHTTPServer/HTTPAuthenticationRequest.m
  92. +29 −29 Xcode/WebServerIPhone/Vendor/CocoaHTTPServer/HTTPConnection.h
  93. +2,063 −2,063 Xcode/WebServerIPhone/Vendor/CocoaHTTPServer/HTTPConnection.m
  94. +1 −1  Xcode/WebServerIPhone/Vendor/CocoaHTTPServer/HTTPMessage.h
  95. +39 −39 Xcode/WebServerIPhone/Vendor/CocoaHTTPServer/HTTPMessage.m
  96. +30 −30 Xcode/WebServerIPhone/Vendor/CocoaHTTPServer/HTTPServer.h
  97. +465 −465 Xcode/WebServerIPhone/Vendor/CocoaHTTPServer/HTTPServer.m
  98. +13 −13 Xcode/WebServerIPhone/Vendor/CocoaHTTPServer/Mime/MultipartFormDataParser.h
  99. +361 −361 Xcode/WebServerIPhone/Vendor/CocoaHTTPServer/Mime/MultipartFormDataParser.m
  100. +47 −47 Xcode/WebServerIPhone/Vendor/CocoaHTTPServer/Mime/MultipartMessageHeader.m
  101. +6 −6 Xcode/WebServerIPhone/Vendor/CocoaHTTPServer/Mime/MultipartMessageHeaderField.h
  102. +154 −154 Xcode/WebServerIPhone/Vendor/CocoaHTTPServer/Mime/MultipartMessageHeaderField.m
  103. +20 −20 Xcode/WebServerIPhone/Vendor/CocoaHTTPServer/Responses/HTTPAsyncFileResponse.h
  104. +301 −301 Xcode/WebServerIPhone/Vendor/CocoaHTTPServer/Responses/HTTPAsyncFileResponse.m
  105. +2 −2 Xcode/WebServerIPhone/Vendor/CocoaHTTPServer/Responses/HTTPDataResponse.h
  106. +36 −36 Xcode/WebServerIPhone/Vendor/CocoaHTTPServer/Responses/HTTPDataResponse.m
  107. +2 −2 Xcode/WebServerIPhone/Vendor/CocoaHTTPServer/Responses/HTTPDynamicFileResponse.h
  108. +243 −243 Xcode/WebServerIPhone/Vendor/CocoaHTTPServer/Responses/HTTPDynamicFileResponse.m
  109. +11 −11 Xcode/WebServerIPhone/Vendor/CocoaHTTPServer/Responses/HTTPFileResponse.h
  110. +172 −172 Xcode/WebServerIPhone/Vendor/CocoaHTTPServer/Responses/HTTPFileResponse.m
  111. +1 −1  Xcode/WebServerIPhone/Vendor/CocoaHTTPServer/Responses/HTTPRedirectResponse.h
  112. +22 −22 Xcode/WebServerIPhone/Vendor/CocoaHTTPServer/Responses/HTTPRedirectResponse.m
  113. +12 −12 Xcode/WebServerIPhone/Vendor/CocoaHTTPServer/WebSocket.h
  114. +573 −573 Xcode/WebServerIPhone/Vendor/CocoaHTTPServer/WebSocket.m
View
2  Lumberjack/DDASLLogger.h
@@ -28,7 +28,7 @@
@interface DDASLLogger : DDAbstractLogger <DDLogger>
{
- aslclient client;
+ aslclient client;
}
+ (instancetype)sharedInstance;
View
96 Lumberjack/DDASLLogger.m
@@ -31,70 +31,70 @@ @implementation DDASLLogger
**/
+ (void)initialize
{
- static BOOL initialized = NO;
- if (!initialized)
- {
- initialized = YES;
-
- sharedInstance = [[[self class] alloc] init];
- }
+ static BOOL initialized = NO;
+ if (!initialized)
+ {
+ initialized = YES;
+
+ sharedInstance = [[[self class] alloc] init];
+ }
}
+ (instancetype)sharedInstance
{
- return sharedInstance;
+ return sharedInstance;
}
- (id)init
{
- if (sharedInstance != nil)
- {
- return nil;
- }
-
- if ((self = [super init]))
- {
- // A default asl client is provided for the main thread,
- // but background threads need to create their own client.
-
- client = asl_open(NULL, "com.apple.console", 0);
- }
- return self;
+ if (sharedInstance != nil)
+ {
+ return nil;
+ }
+
+ if ((self = [super init]))
+ {
+ // A default asl client is provided for the main thread,
+ // but background threads need to create their own client.
+
+ client = asl_open(NULL, "com.apple.console", 0);
+ }
+ return self;
}
- (void)logMessage:(DDLogMessage *)logMessage
{
- NSString *logMsg = logMessage->logMsg;
-
- if (formatter)
- {
- logMsg = [formatter formatLogMessage:logMessage];
- }
-
- if (logMsg)
- {
- const char *msg = [logMsg UTF8String];
-
- int aslLogLevel;
- switch (logMessage->logFlag)
- {
- // Note: By default ASL will filter anything above level 5 (Notice).
- // So our mappings shouldn't go above that level.
-
- case LOG_FLAG_ERROR : aslLogLevel = ASL_LEVEL_ALERT; break;
- case LOG_FLAG_WARN : aslLogLevel = ASL_LEVEL_CRIT; break;
- case LOG_FLAG_INFO : aslLogLevel = ASL_LEVEL_ERR; break;
- case LOG_FLAG_DEBUG : aslLogLevel = ASL_LEVEL_WARNING; break;
- default : aslLogLevel = ASL_LEVEL_NOTICE; break;
- }
-
- asl_log(client, NULL, aslLogLevel, "%s", msg);
- }
+ NSString *logMsg = logMessage->logMsg;
+
+ if (formatter)
+ {
+ logMsg = [formatter formatLogMessage:logMessage];
+ }
+
+ if (logMsg)
+ {
+ const char *msg = [logMsg UTF8String];
+
+ int aslLogLevel;
+ switch (logMessage->logFlag)
+ {
+ // Note: By default ASL will filter anything above level 5 (Notice).
+ // So our mappings shouldn't go above that level.
+
+ case LOG_FLAG_ERROR : aslLogLevel = ASL_LEVEL_ALERT; break;
+ case LOG_FLAG_WARN : aslLogLevel = ASL_LEVEL_CRIT; break;
+ case LOG_FLAG_INFO : aslLogLevel = ASL_LEVEL_ERR; break;
+ case LOG_FLAG_DEBUG : aslLogLevel = ASL_LEVEL_WARNING; break;
+ default : aslLogLevel = ASL_LEVEL_NOTICE; break;
+ }
+
+ asl_log(client, NULL, aslLogLevel, "%s", msg);
+ }
}
- (NSString *)loggerName
{
- return @"cocoa.lumberjack.aslLogger";
+ return @"cocoa.lumberjack.aslLogger";
}
@end
View
24 Lumberjack/DDAbstractDatabaseLogger.h
@@ -21,18 +21,18 @@
@interface DDAbstractDatabaseLogger : DDAbstractLogger {
@protected
- NSUInteger saveThreshold;
- NSTimeInterval saveInterval;
- NSTimeInterval maxAge;
- NSTimeInterval deleteInterval;
- BOOL deleteOnEverySave;
-
- BOOL saveTimerSuspended;
- NSUInteger unsavedCount;
- dispatch_time_t unsavedTime;
- dispatch_source_t saveTimer;
- dispatch_time_t lastDeleteTime;
- dispatch_source_t deleteTimer;
+ NSUInteger saveThreshold;
+ NSTimeInterval saveInterval;
+ NSTimeInterval maxAge;
+ NSTimeInterval deleteInterval;
+ BOOL deleteOnEverySave;
+
+ BOOL saveTimerSuspended;
+ NSUInteger unsavedCount;
+ dispatch_time_t unsavedTime;
+ dispatch_source_t saveTimer;
+ dispatch_time_t lastDeleteTime;
+ dispatch_source_t deleteTimer;
}
/**
View
1,086 Lumberjack/DDAbstractDatabaseLogger.m
@@ -26,21 +26,21 @@ @implementation DDAbstractDatabaseLogger
- (id)init
{
- if ((self = [super init]))
- {
+ if ((self = [super init]))
+ {
saveThreshold = 500;
- saveInterval = 60; // 60 seconds
- maxAge = (60 * 60 * 24 * 7); // 7 days
- deleteInterval = (60 * 5); // 5 minutes
- }
- return self;
+ saveInterval = 60; // 60 seconds
+ maxAge = (60 * 60 * 24 * 7); // 7 days
+ deleteInterval = (60 * 5); // 5 minutes
+ }
+ return self;
}
- (void)dealloc
{
- [self destroySaveTimer];
- [self destroyDeleteTimer];
-
+ [self destroySaveTimer];
+ [self destroyDeleteTimer];
+
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -49,27 +49,27 @@ - (void)dealloc
- (BOOL)db_log:(DDLogMessage *)logMessage
{
- // Override me and add your implementation.
- //
- // Return YES if an item was added to the buffer.
- // Return NO if the logMessage was ignored.
-
- return NO;
+ // Override me and add your implementation.
+ //
+ // Return YES if an item was added to the buffer.
+ // Return NO if the logMessage was ignored.
+
+ return NO;
}
- (void)db_save
{
- // Override me and add your implementation.
+ // Override me and add your implementation.
}
- (void)db_delete
{
- // Override me and add your implementation.
+ // Override me and add your implementation.
}
- (void)db_saveAndDelete
{
- // Override me and add your implementation.
+ // Override me and add your implementation.
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -78,32 +78,32 @@ - (void)db_saveAndDelete
- (void)performSaveAndSuspendSaveTimer
{
- if (unsavedCount > 0)
- {
- if (deleteOnEverySave)
- [self db_saveAndDelete];
- else
- [self db_save];
- }
-
- unsavedCount = 0;
- unsavedTime = 0;
-
- if (saveTimer && !saveTimerSuspended)
- {
- dispatch_suspend(saveTimer);
- saveTimerSuspended = YES;
- }
+ if (unsavedCount > 0)
+ {
+ if (deleteOnEverySave)
+ [self db_saveAndDelete];
+ else
+ [self db_save];
+ }
+
+ unsavedCount = 0;
+ unsavedTime = 0;
+
+ if (saveTimer && !saveTimerSuspended)
+ {
+ dispatch_suspend(saveTimer);
+ saveTimerSuspended = YES;
+ }
}
- (void)performDelete
{
- if (maxAge > 0.0)
- {
- [self db_delete];
-
- lastDeleteTime = dispatch_time(DISPATCH_TIME_NOW, 0);
- }
+ if (maxAge > 0.0)
+ {
+ [self db_delete];
+
+ lastDeleteTime = dispatch_time(DISPATCH_TIME_NOW, 0);
+ }
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -112,88 +112,88 @@ - (void)performDelete
- (void)destroySaveTimer
{
- if (saveTimer)
- {
- dispatch_source_cancel(saveTimer);
- if (saveTimerSuspended)
- {
- // Must resume a timer before releasing it (or it will crash)
- dispatch_resume(saveTimer);
- saveTimerSuspended = NO;
- }
- #if !OS_OBJECT_USE_OBJC
- dispatch_release(saveTimer);
- #endif
- saveTimer = NULL;
- }
+ if (saveTimer)
+ {
+ dispatch_source_cancel(saveTimer);
+ if (saveTimerSuspended)
+ {
+ // Must resume a timer before releasing it (or it will crash)
+ dispatch_resume(saveTimer);
+ saveTimerSuspended = NO;
+ }
+ #if !OS_OBJECT_USE_OBJC
+ dispatch_release(saveTimer);
+ #endif
+ saveTimer = NULL;
+ }
}
- (void)updateAndResumeSaveTimer
{
- if ((saveTimer != NULL) && (saveInterval > 0.0) && (unsavedTime > 0.0))
- {
- uint64_t interval = (uint64_t)(saveInterval * NSEC_PER_SEC);
- dispatch_time_t startTime = dispatch_time(unsavedTime, interval);
-
- dispatch_source_set_timer(saveTimer, startTime, interval, 1.0);
-
- if (saveTimerSuspended)
- {
- dispatch_resume(saveTimer);
- saveTimerSuspended = NO;
- }
- }
+ if ((saveTimer != NULL) && (saveInterval > 0.0) && (unsavedTime > 0.0))
+ {
+ uint64_t interval = (uint64_t)(saveInterval * NSEC_PER_SEC);
+ dispatch_time_t startTime = dispatch_time(unsavedTime, interval);
+
+ dispatch_source_set_timer(saveTimer, startTime, interval, 1.0);
+
+ if (saveTimerSuspended)
+ {
+ dispatch_resume(saveTimer);
+ saveTimerSuspended = NO;
+ }
+ }
}
- (void)createSuspendedSaveTimer
{
- if ((saveTimer == NULL) && (saveInterval > 0.0))
- {
- saveTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, loggerQueue);
-
- dispatch_source_set_event_handler(saveTimer, ^{ @autoreleasepool {
-
- [self performSaveAndSuspendSaveTimer];
-
- }});
-
- saveTimerSuspended = YES;
- }
+ if ((saveTimer == NULL) && (saveInterval > 0.0))
+ {
+ saveTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, loggerQueue);
+
+ dispatch_source_set_event_handler(saveTimer, ^{ @autoreleasepool {
+
+ [self performSaveAndSuspendSaveTimer];
+
+ }});
+
+ saveTimerSuspended = YES;
+ }
}
- (void)destroyDeleteTimer
{
- if (deleteTimer)
- {
- dispatch_source_cancel(deleteTimer);
- #if !OS_OBJECT_USE_OBJC
- dispatch_release(deleteTimer);
- #endif
- deleteTimer = NULL;
- }
+ if (deleteTimer)
+ {
+ dispatch_source_cancel(deleteTimer);
+ #if !OS_OBJECT_USE_OBJC
+ dispatch_release(deleteTimer);
+ #endif
+ deleteTimer = NULL;
+ }
}
- (void)updateDeleteTimer
{
- if ((deleteTimer != NULL) && (deleteInterval > 0.0) && (maxAge > 0.0))
- {
- uint64_t interval = (uint64_t)(deleteInterval * NSEC_PER_SEC);
- dispatch_time_t startTime;
-
- if (lastDeleteTime > 0)
- startTime = dispatch_time(lastDeleteTime, interval);
- else
- startTime = dispatch_time(DISPATCH_TIME_NOW, interval);
-
- dispatch_source_set_timer(deleteTimer, startTime, interval, 1.0);
- }
+ if ((deleteTimer != NULL) && (deleteInterval > 0.0) && (maxAge > 0.0))
+ {
+ uint64_t interval = (uint64_t)(deleteInterval * NSEC_PER_SEC);
+ dispatch_time_t startTime;
+
+ if (lastDeleteTime > 0)
+ startTime = dispatch_time(lastDeleteTime, interval);
+ else
+ startTime = dispatch_time(DISPATCH_TIME_NOW, interval);
+
+ dispatch_source_set_timer(deleteTimer, startTime, interval, 1.0);
+ }
}
- (void)createAndStartDeleteTimer
{
- if ((deleteTimer == NULL) && (deleteInterval > 0.0) && (maxAge > 0.0))
- {
- deleteTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, loggerQueue);
+ if ((deleteTimer == NULL) && (deleteInterval > 0.0) && (maxAge > 0.0))
+ {
+ deleteTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, loggerQueue);
if (deleteTimer != NULL) {
dispatch_source_set_event_handler(deleteTimer, ^{ @autoreleasepool {
@@ -206,7 +206,7 @@ - (void)createAndStartDeleteTimer
if (deleteTimer != NULL) dispatch_resume(deleteTimer);
}
- }
+ }
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -215,432 +215,432 @@ - (void)createAndStartDeleteTimer
- (NSUInteger)saveThreshold
{
- // The design of this method is taken from the DDAbstractLogger implementation.
- // For extensive documentation please refer to the DDAbstractLogger implementation.
-
- // Note: The internal implementation MUST access the colorsEnabled variable directly,
- // This method is designed explicitly for external access.
- //
- // Using "self." syntax to go through this method will cause immediate deadlock.
- // This is the intended result. Fix it by accessing the ivar directly.
- // Great strides have been take to ensure this is safe to do. Plus it's MUCH faster.
-
- NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
- NSAssert(![self isOnInternalLoggerQueue], @"MUST access ivar directly, NOT via self.* syntax.");
-
- dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
-
- __block NSUInteger result;
-
- dispatch_sync(globalLoggingQueue, ^{
- dispatch_sync(loggerQueue, ^{
- result = saveThreshold;
- });
- });
-
- return result;
+ // The design of this method is taken from the DDAbstractLogger implementation.
+ // For extensive documentation please refer to the DDAbstractLogger implementation.
+
+ // Note: The internal implementation MUST access the colorsEnabled variable directly,
+ // This method is designed explicitly for external access.
+ //
+ // Using "self." syntax to go through this method will cause immediate deadlock.
+ // This is the intended result. Fix it by accessing the ivar directly.
+ // Great strides have been take to ensure this is safe to do. Plus it's MUCH faster.
+
+ NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
+ NSAssert(![self isOnInternalLoggerQueue], @"MUST access ivar directly, NOT via self.* syntax.");
+
+ dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
+
+ __block NSUInteger result;
+
+ dispatch_sync(globalLoggingQueue, ^{
+ dispatch_sync(loggerQueue, ^{
+ result = saveThreshold;
+ });
+ });
+
+ return result;
}
- (void)setSaveThreshold:(NSUInteger)threshold
{
- dispatch_block_t block = ^{ @autoreleasepool {
-
- if (saveThreshold != threshold)
- {
- saveThreshold = threshold;
-
- // Since the saveThreshold has changed,
- // we check to see if the current unsavedCount has surpassed the new threshold.
- //
- // If it has, we immediately save the log.
-
- if ((unsavedCount >= saveThreshold) && (saveThreshold > 0))
- {
- [self performSaveAndSuspendSaveTimer];
- }
- }
- }};
-
- // The design of the setter logic below is taken from the DDAbstractLogger implementation.
- // For documentation please refer to the DDAbstractLogger implementation.
-
- if ([self isOnInternalLoggerQueue])
- {
- block();
- }
- else
- {
- dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
- NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
-
- dispatch_async(globalLoggingQueue, ^{
- dispatch_async(loggerQueue, block);
- });
- }
+ dispatch_block_t block = ^{ @autoreleasepool {
+
+ if (saveThreshold != threshold)
+ {
+ saveThreshold = threshold;
+
+ // Since the saveThreshold has changed,
+ // we check to see if the current unsavedCount has surpassed the new threshold.
+ //
+ // If it has, we immediately save the log.
+
+ if ((unsavedCount >= saveThreshold) && (saveThreshold > 0))
+ {
+ [self performSaveAndSuspendSaveTimer];
+ }
+ }
+ }};
+
+ // The design of the setter logic below is taken from the DDAbstractLogger implementation.
+ // For documentation please refer to the DDAbstractLogger implementation.
+
+ if ([self isOnInternalLoggerQueue])
+ {
+ block();
+ }
+ else
+ {
+ dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
+ NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
+
+ dispatch_async(globalLoggingQueue, ^{
+ dispatch_async(loggerQueue, block);
+ });
+ }
}
- (NSTimeInterval)saveInterval
{
- // The design of this method is taken from the DDAbstractLogger implementation.
- // For extensive documentation please refer to the DDAbstractLogger implementation.
-
- // Note: The internal implementation MUST access the colorsEnabled variable directly,
- // This method is designed explicitly for external access.
- //
- // Using "self." syntax to go through this method will cause immediate deadlock.
- // This is the intended result. Fix it by accessing the ivar directly.
- // Great strides have been take to ensure this is safe to do. Plus it's MUCH faster.
-
- NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
- NSAssert(![self isOnInternalLoggerQueue], @"MUST access ivar directly, NOT via self.* syntax.");
-
- dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
-
- __block NSTimeInterval result;
-
- dispatch_sync(globalLoggingQueue, ^{
- dispatch_sync(loggerQueue, ^{
- result = saveInterval;
- });
- });
-
- return result;
+ // The design of this method is taken from the DDAbstractLogger implementation.
+ // For extensive documentation please refer to the DDAbstractLogger implementation.
+
+ // Note: The internal implementation MUST access the colorsEnabled variable directly,
+ // This method is designed explicitly for external access.
+ //
+ // Using "self." syntax to go through this method will cause immediate deadlock.
+ // This is the intended result. Fix it by accessing the ivar directly.
+ // Great strides have been take to ensure this is safe to do. Plus it's MUCH faster.
+
+ NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
+ NSAssert(![self isOnInternalLoggerQueue], @"MUST access ivar directly, NOT via self.* syntax.");
+
+ dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
+
+ __block NSTimeInterval result;
+
+ dispatch_sync(globalLoggingQueue, ^{
+ dispatch_sync(loggerQueue, ^{
+ result = saveInterval;
+ });
+ });
+
+ return result;
}
- (void)setSaveInterval:(NSTimeInterval)interval
{
- dispatch_block_t block = ^{ @autoreleasepool {
-
- // C99 recommended floating point comparison macro
- // Read: isLessThanOrGreaterThan(floatA, floatB)
-
- if (/* saveInterval != interval */ islessgreater(saveInterval, interval))
- {
- saveInterval = interval;
-
- // There are several cases we need to handle here.
- //
- // 1. If the saveInterval was previously enabled and it just got disabled,
- // then we need to stop the saveTimer. (And we might as well release it.)
- //
- // 2. If the saveInterval was previously disabled and it just got enabled,
- // then we need to setup the saveTimer. (Plus we might need to do an immediate save.)
- //
- // 3. If the saveInterval increased, then we need to reset the timer so that it fires at the later date.
- //
- // 4. If the saveInterval decreased, then we need to reset the timer so that it fires at an earlier date.
- // (Plus we might need to do an immediate save.)
-
- if (saveInterval > 0.0)
- {
- if (saveTimer == NULL)
- {
- // Handles #2
- //
- // Since the saveTimer uses the unsavedTime to calculate it's first fireDate,
- // if a save is needed the timer will fire immediately.
-
- [self createSuspendedSaveTimer];
- [self updateAndResumeSaveTimer];
- }
- else
- {
- // Handles #3
- // Handles #4
- //
- // Since the saveTimer uses the unsavedTime to calculate it's first fireDate,
- // if a save is needed the timer will fire immediately.
-
- [self updateAndResumeSaveTimer];
- }
- }
- else if (saveTimer)
- {
- // Handles #1
-
- [self destroySaveTimer];
- }
- }
- }};
-
- // The design of the setter logic below is taken from the DDAbstractLogger implementation.
- // For documentation please refer to the DDAbstractLogger implementation.
-
- if ([self isOnInternalLoggerQueue])
- {
- block();
- }
- else
- {
- dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
- NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
-
- dispatch_async(globalLoggingQueue, ^{
- dispatch_async(loggerQueue, block);
- });
- }
+ dispatch_block_t block = ^{ @autoreleasepool {
+
+ // C99 recommended floating point comparison macro
+ // Read: isLessThanOrGreaterThan(floatA, floatB)
+
+ if (/* saveInterval != interval */ islessgreater(saveInterval, interval))
+ {
+ saveInterval = interval;
+
+ // There are several cases we need to handle here.
+ //
+ // 1. If the saveInterval was previously enabled and it just got disabled,
+ // then we need to stop the saveTimer. (And we might as well release it.)
+ //
+ // 2. If the saveInterval was previously disabled and it just got enabled,
+ // then we need to setup the saveTimer. (Plus we might need to do an immediate save.)
+ //
+ // 3. If the saveInterval increased, then we need to reset the timer so that it fires at the later date.
+ //
+ // 4. If the saveInterval decreased, then we need to reset the timer so that it fires at an earlier date.
+ // (Plus we might need to do an immediate save.)
+
+ if (saveInterval > 0.0)
+ {
+ if (saveTimer == NULL)
+ {
+ // Handles #2
+ //
+ // Since the saveTimer uses the unsavedTime to calculate it's first fireDate,
+ // if a save is needed the timer will fire immediately.
+
+ [self createSuspendedSaveTimer];
+ [self updateAndResumeSaveTimer];
+ }
+ else
+ {
+ // Handles #3
+ // Handles #4
+ //
+ // Since the saveTimer uses the unsavedTime to calculate it's first fireDate,
+ // if a save is needed the timer will fire immediately.
+
+ [self updateAndResumeSaveTimer];
+ }
+ }
+ else if (saveTimer)
+ {
+ // Handles #1
+
+ [self destroySaveTimer];
+ }
+ }
+ }};
+
+ // The design of the setter logic below is taken from the DDAbstractLogger implementation.
+ // For documentation please refer to the DDAbstractLogger implementation.
+
+ if ([self isOnInternalLoggerQueue])
+ {
+ block();
+ }
+ else
+ {
+ dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
+ NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
+
+ dispatch_async(globalLoggingQueue, ^{
+ dispatch_async(loggerQueue, block);
+ });
+ }
}
- (NSTimeInterval)maxAge
{
- // The design of this method is taken from the DDAbstractLogger implementation.
- // For extensive documentation please refer to the DDAbstractLogger implementation.
-
- // Note: The internal implementation MUST access the colorsEnabled variable directly,
- // This method is designed explicitly for external access.
- //
- // Using "self." syntax to go through this method will cause immediate deadlock.
- // This is the intended result. Fix it by accessing the ivar directly.
- // Great strides have been take to ensure this is safe to do. Plus it's MUCH faster.
-
- NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
- NSAssert(![self isOnInternalLoggerQueue], @"MUST access ivar directly, NOT via self.* syntax.");
-
- dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
-
- __block NSTimeInterval result;
-
- dispatch_sync(globalLoggingQueue, ^{
- dispatch_sync(loggerQueue, ^{
- result = maxAge;
- });
- });
-
- return result;
+ // The design of this method is taken from the DDAbstractLogger implementation.
+ // For extensive documentation please refer to the DDAbstractLogger implementation.
+
+ // Note: The internal implementation MUST access the colorsEnabled variable directly,
+ // This method is designed explicitly for external access.
+ //
+ // Using "self." syntax to go through this method will cause immediate deadlock.
+ // This is the intended result. Fix it by accessing the ivar directly.
+ // Great strides have been take to ensure this is safe to do. Plus it's MUCH faster.
+
+ NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
+ NSAssert(![self isOnInternalLoggerQueue], @"MUST access ivar directly, NOT via self.* syntax.");
+
+ dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
+
+ __block NSTimeInterval result;
+
+ dispatch_sync(globalLoggingQueue, ^{
+ dispatch_sync(loggerQueue, ^{
+ result = maxAge;
+ });
+ });
+
+ return result;
}
- (void)setMaxAge:(NSTimeInterval)interval
{
- dispatch_block_t block = ^{ @autoreleasepool {
-
- // C99 recommended floating point comparison macro
- // Read: isLessThanOrGreaterThan(floatA, floatB)
-
- if (/* maxAge != interval */ islessgreater(maxAge, interval))
- {
- NSTimeInterval oldMaxAge = maxAge;
- NSTimeInterval newMaxAge = interval;
-
- maxAge = interval;
-
- // There are several cases we need to handle here.
- //
- // 1. If the maxAge was previously enabled and it just got disabled,
- // then we need to stop the deleteTimer. (And we might as well release it.)
- //
- // 2. If the maxAge was previously disabled and it just got enabled,
- // then we need to setup the deleteTimer. (Plus we might need to do an immediate delete.)
- //
- // 3. If the maxAge was increased,
- // then we don't need to do anything.
- //
- // 4. If the maxAge was decreased,
- // then we should do an immediate delete.
-
- BOOL shouldDeleteNow = NO;
-
- if (oldMaxAge > 0.0)
- {
- if (newMaxAge <= 0.0)
- {
- // Handles #1
-
- [self destroyDeleteTimer];
- }
- else if (oldMaxAge > newMaxAge)
- {
- // Handles #4
- shouldDeleteNow = YES;
- }
- }
- else if (newMaxAge > 0.0)
- {
- // Handles #2
- shouldDeleteNow = YES;
- }
-
- if (shouldDeleteNow)
- {
- [self performDelete];
-
- if (deleteTimer)
- [self updateDeleteTimer];
- else
- [self createAndStartDeleteTimer];
- }
- }
- }};
-
- // The design of the setter logic below is taken from the DDAbstractLogger implementation.
- // For documentation please refer to the DDAbstractLogger implementation.
-
- if ([self isOnInternalLoggerQueue])
- {
- block();
- }
- else
- {
- dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
- NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
-
- dispatch_async(globalLoggingQueue, ^{
- dispatch_async(loggerQueue, block);
- });
- }
+ dispatch_block_t block = ^{ @autoreleasepool {
+
+ // C99 recommended floating point comparison macro
+ // Read: isLessThanOrGreaterThan(floatA, floatB)
+
+ if (/* maxAge != interval */ islessgreater(maxAge, interval))
+ {
+ NSTimeInterval oldMaxAge = maxAge;
+ NSTimeInterval newMaxAge = interval;
+
+ maxAge = interval;
+
+ // There are several cases we need to handle here.
+ //
+ // 1. If the maxAge was previously enabled and it just got disabled,
+ // then we need to stop the deleteTimer. (And we might as well release it.)
+ //
+ // 2. If the maxAge was previously disabled and it just got enabled,
+ // then we need to setup the deleteTimer. (Plus we might need to do an immediate delete.)
+ //
+ // 3. If the maxAge was increased,
+ // then we don't need to do anything.
+ //
+ // 4. If the maxAge was decreased,
+ // then we should do an immediate delete.
+
+ BOOL shouldDeleteNow = NO;
+
+ if (oldMaxAge > 0.0)
+ {
+ if (newMaxAge <= 0.0)
+ {
+ // Handles #1
+
+ [self destroyDeleteTimer];
+ }
+ else if (oldMaxAge > newMaxAge)
+ {
+ // Handles #4
+ shouldDeleteNow = YES;
+ }
+ }
+ else if (newMaxAge > 0.0)
+ {
+ // Handles #2
+ shouldDeleteNow = YES;
+ }
+
+ if (shouldDeleteNow)
+ {
+ [self performDelete];
+
+ if (deleteTimer)
+ [self updateDeleteTimer];
+ else
+ [self createAndStartDeleteTimer];
+ }
+ }
+ }};
+
+ // The design of the setter logic below is taken from the DDAbstractLogger implementation.
+ // For documentation please refer to the DDAbstractLogger implementation.
+
+ if ([self isOnInternalLoggerQueue])
+ {
+ block();
+ }
+ else
+ {
+ dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
+ NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
+
+ dispatch_async(globalLoggingQueue, ^{
+ dispatch_async(loggerQueue, block);
+ });
+ }
}
- (NSTimeInterval)deleteInterval
{
- // The design of this method is taken from the DDAbstractLogger implementation.
- // For extensive documentation please refer to the DDAbstractLogger implementation.
-
- // Note: The internal implementation MUST access the colorsEnabled variable directly,
- // This method is designed explicitly for external access.
- //
- // Using "self." syntax to go through this method will cause immediate deadlock.
- // This is the intended result. Fix it by accessing the ivar directly.
- // Great strides have been take to ensure this is safe to do. Plus it's MUCH faster.
-
- NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
- NSAssert(![self isOnInternalLoggerQueue], @"MUST access ivar directly, NOT via self.* syntax.");
-
- dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
-
- __block NSTimeInterval result;
-
- dispatch_sync(globalLoggingQueue, ^{
- dispatch_sync(loggerQueue, ^{
- result = deleteInterval;
- });
- });
-
- return result;
+ // The design of this method is taken from the DDAbstractLogger implementation.
+ // For extensive documentation please refer to the DDAbstractLogger implementation.
+
+ // Note: The internal implementation MUST access the colorsEnabled variable directly,
+ // This method is designed explicitly for external access.
+ //
+ // Using "self." syntax to go through this method will cause immediate deadlock.
+ // This is the intended result. Fix it by accessing the ivar directly.
+ // Great strides have been take to ensure this is safe to do. Plus it's MUCH faster.
+
+ NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
+ NSAssert(![self isOnInternalLoggerQueue], @"MUST access ivar directly, NOT via self.* syntax.");
+
+ dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
+
+ __block NSTimeInterval result;
+
+ dispatch_sync(globalLoggingQueue, ^{
+ dispatch_sync(loggerQueue, ^{
+ result = deleteInterval;
+ });
+ });
+
+ return result;
}
- (void)setDeleteInterval:(NSTimeInterval)interval
{
- dispatch_block_t block = ^{ @autoreleasepool {
-
- // C99 recommended floating point comparison macro
- // Read: isLessThanOrGreaterThan(floatA, floatB)
-
- if (/* deleteInterval != interval */ islessgreater(deleteInterval, interval))
- {
- deleteInterval = interval;
-
- // There are several cases we need to handle here.
- //
- // 1. If the deleteInterval was previously enabled and it just got disabled,
- // then we need to stop the deleteTimer. (And we might as well release it.)
- //
- // 2. If the deleteInterval was previously disabled and it just got enabled,
- // then we need to setup the deleteTimer. (Plus we might need to do an immediate delete.)
- //
- // 3. If the deleteInterval increased, then we need to reset the timer so that it fires at the later date.
- //
- // 4. If the deleteInterval decreased, then we need to reset the timer so that it fires at an earlier date.
- // (Plus we might need to do an immediate delete.)
-
- if (deleteInterval > 0.0)
- {
- if (deleteTimer == NULL)
- {
- // Handles #2
- //
- // Since the deleteTimer uses the lastDeleteTime to calculate it's first fireDate,
- // if a delete is needed the timer will fire immediately.
-
- [self createAndStartDeleteTimer];
- }
- else
- {
- // Handles #3
- // Handles #4
- //
- // Since the deleteTimer uses the lastDeleteTime to calculate it's first fireDate,
- // if a save is needed the timer will fire immediately.
-
- [self updateDeleteTimer];
- }
- }
- else if (deleteTimer)
- {
- // Handles #1
-
- [self destroyDeleteTimer];
- }
- }
- }};
-
- // The design of the setter logic below is taken from the DDAbstractLogger implementation.
- // For documentation please refer to the DDAbstractLogger implementation.
-
- if ([self isOnInternalLoggerQueue])
- {
- block();
- }
- else
- {
- dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
- NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
-
- dispatch_async(globalLoggingQueue, ^{
- dispatch_async(loggerQueue, block);
- });
- }
+ dispatch_block_t block = ^{ @autoreleasepool {
+
+ // C99 recommended floating point comparison macro
+ // Read: isLessThanOrGreaterThan(floatA, floatB)
+
+ if (/* deleteInterval != interval */ islessgreater(deleteInterval, interval))
+ {
+ deleteInterval = interval;
+
+ // There are several cases we need to handle here.
+ //
+ // 1. If the deleteInterval was previously enabled and it just got disabled,
+ // then we need to stop the deleteTimer. (And we might as well release it.)
+ //
+ // 2. If the deleteInterval was previously disabled and it just got enabled,
+ // then we need to setup the deleteTimer. (Plus we might need to do an immediate delete.)
+ //
+ // 3. If the deleteInterval increased, then we need to reset the timer so that it fires at the later date.
+ //
+ // 4. If the deleteInterval decreased, then we need to reset the timer so that it fires at an earlier date.
+ // (Plus we might need to do an immediate delete.)
+
+ if (deleteInterval > 0.0)
+ {
+ if (deleteTimer == NULL)
+ {
+ // Handles #2
+ //
+ // Since the deleteTimer uses the lastDeleteTime to calculate it's first fireDate,
+ // if a delete is needed the timer will fire immediately.
+
+ [self createAndStartDeleteTimer];
+ }
+ else
+ {
+ // Handles #3
+ // Handles #4
+ //
+ // Since the deleteTimer uses the lastDeleteTime to calculate it's first fireDate,
+ // if a save is needed the timer will fire immediately.
+
+ [self updateDeleteTimer];
+ }
+ }
+ else if (deleteTimer)
+ {
+ // Handles #1
+
+ [self destroyDeleteTimer];
+ }
+ }
+ }};
+
+ // The design of the setter logic below is taken from the DDAbstractLogger implementation.
+ // For documentation please refer to the DDAbstractLogger implementation.
+
+ if ([self isOnInternalLoggerQueue])
+ {
+ block();
+ }
+ else
+ {
+ dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
+ NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
+
+ dispatch_async(globalLoggingQueue, ^{
+ dispatch_async(loggerQueue, block);
+ });
+ }
}
- (BOOL)deleteOnEverySave
{
- // The design of this method is taken from the DDAbstractLogger implementation.
- // For extensive documentation please refer to the DDAbstractLogger implementation.
-
- // Note: The internal implementation MUST access the colorsEnabled variable directly,
- // This method is designed explicitly for external access.
- //
- // Using "self." syntax to go through this method will cause immediate deadlock.
- // This is the intended result. Fix it by accessing the ivar directly.
- // Great strides have been take to ensure this is safe to do. Plus it's MUCH faster.
-
- NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
- NSAssert(![self isOnInternalLoggerQueue], @"MUST access ivar directly, NOT via self.* syntax.");
-
- dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
-
- __block BOOL result;
-
- dispatch_sync(globalLoggingQueue, ^{
- dispatch_sync(loggerQueue, ^{
- result = deleteOnEverySave;
- });
- });
-
- return result;
+ // The design of this method is taken from the DDAbstractLogger implementation.
+ // For extensive documentation please refer to the DDAbstractLogger implementation.
+
+ // Note: The internal implementation MUST access the colorsEnabled variable directly,
+ // This method is designed explicitly for external access.
+ //
+ // Using "self." syntax to go through this method will cause immediate deadlock.
+ // This is the intended result. Fix it by accessing the ivar directly.
+ // Great strides have been take to ensure this is safe to do. Plus it's MUCH faster.
+
+ NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
+ NSAssert(![self isOnInternalLoggerQueue], @"MUST access ivar directly, NOT via self.* syntax.");
+
+ dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
+
+ __block BOOL result;
+
+ dispatch_sync(globalLoggingQueue, ^{
+ dispatch_sync(loggerQueue, ^{
+ result = deleteOnEverySave;
+ });
+ });
+
+ return result;
}
- (void)setDeleteOnEverySave:(BOOL)flag
{
- dispatch_block_t block = ^{
-
- deleteOnEverySave = flag;
- };
-
- // The design of the setter logic below is taken from the DDAbstractLogger implementation.
- // For documentation please refer to the DDAbstractLogger implementation.
-
- if ([self isOnInternalLoggerQueue])
- {
- block();
- }
- else
- {
- dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
- NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
-
- dispatch_async(globalLoggingQueue, ^{
- dispatch_async(loggerQueue, block);
- });
- }
+ dispatch_block_t block = ^{
+
+ deleteOnEverySave = flag;
+ };
+
+ // The design of the setter logic below is taken from the DDAbstractLogger implementation.
+ // For documentation please refer to the DDAbstractLogger implementation.
+
+ if ([self isOnInternalLoggerQueue])
+ {
+ block();
+ }
+ else
+ {
+ dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
+ NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
+
+ dispatch_async(globalLoggingQueue, ^{
+ dispatch_async(loggerQueue, block);
+ });
+ }
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -649,28 +649,28 @@ - (void)setDeleteOnEverySave:(BOOL)flag
- (void)savePendingLogEntries
{
- dispatch_block_t block = ^{ @autoreleasepool {
-
- [self performSaveAndSuspendSaveTimer];
- }};
-
- if ([self isOnInternalLoggerQueue])
- block();
- else
- dispatch_async(loggerQueue, block);
+ dispatch_block_t block = ^{ @autoreleasepool {
+
+ [self performSaveAndSuspendSaveTimer];
+ }};
+
+ if ([self isOnInternalLoggerQueue])
+ block();
+ else
+ dispatch_async(loggerQueue, block);
}
- (void)deleteOldLogEntries
{
- dispatch_block_t block = ^{ @autoreleasepool {
-
- [self performDelete];
- }};
-
- if ([self isOnInternalLoggerQueue])
- block();
- else
- dispatch_async(loggerQueue, block);
+ dispatch_block_t block = ^{ @autoreleasepool {
+
+ [self performDelete];
+ }};
+
+ if ([self isOnInternalLoggerQueue])
+ block();
+ else
+ dispatch_async(loggerQueue, block);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -679,49 +679,49 @@ - (void)deleteOldLogEntries
- (void)didAddLogger
{
- // If you override me be sure to invoke [super didAddLogger];
-
- [self createSuspendedSaveTimer];
-
- [self createAndStartDeleteTimer];
+ // If you override me be sure to invoke [super didAddLogger];
+
+ [self createSuspendedSaveTimer];
+
+ [self createAndStartDeleteTimer];
}
- (void)willRemoveLogger
{
- // If you override me be sure to invoke [super willRemoveLogger];
-
- [self performSaveAndSuspendSaveTimer];
-
- [self destroySaveTimer];
- [self destroyDeleteTimer];
+ // If you override me be sure to invoke [super willRemoveLogger];
+
+ [self performSaveAndSuspendSaveTimer];
+
+ [self destroySaveTimer];
+ [self destroyDeleteTimer];
}
- (void)logMessage:(DDLogMessage *)logMessage
{
- if ([self db_log:logMessage])
- {
- BOOL firstUnsavedEntry = (++unsavedCount == 1);
-
- if ((unsavedCount >= saveThreshold) && (saveThreshold > 0))
- {
- [self performSaveAndSuspendSaveTimer];
- }
- else if (firstUnsavedEntry)
- {
- unsavedTime = dispatch_time(DISPATCH_TIME_NOW, 0);
- [self updateAndResumeSaveTimer];
- }
- }
+ if ([self db_log:logMessage])
+ {
+ BOOL firstUnsavedEntry = (++unsavedCount == 1);
+
+ if ((unsavedCount >= saveThreshold) && (saveThreshold > 0))
+ {
+ [self performSaveAndSuspendSaveTimer];
+ }
+ else if (firstUnsavedEntry)
+ {
+ unsavedTime = dispatch_time(DISPATCH_TIME_NOW, 0);
+ [self updateAndResumeSaveTimer];
+ }
+ }
}
- (void)flush
{
- // This method is invoked by DDLog's flushLog method.
- //
- // It is called automatically when the application quits,
- // or if the developer invokes DDLog's flushLog method prior to crashing or something.
-
- [self performSaveAndSuspendSaveTimer];
+ // This method is invoked by DDLog's flushLog method.
+ //
+ // It is called automatically when the application quits,
+ // or if the developer invokes DDLog's flushLog method prior to crashing or something.
+
+ [self performSaveAndSuspendSaveTimer];
}
@end
View
42 Lumberjack/DDFileLogger.h
@@ -121,8 +121,8 @@ typedef enum {
**/
@interface DDLogFileManagerDefault : NSObject <DDLogFileManager>
{
- NSUInteger maximumNumberOfLogFiles;
- NSString *_logsDirectory;
+ NSUInteger maximumNumberOfLogFiles;
+ NSString *_logsDirectory;
}
@property (readwrite, assign) DDLogFileNamingConvention fileNamingConvention;
@@ -164,7 +164,7 @@ typedef enum {
**/
@interface DDLogFileFormatterDefault : NSObject <DDLogFormatter>
{
- NSDateFormatter *dateFormatter;
+ NSDateFormatter *dateFormatter;
}
- (id)init;
@@ -178,15 +178,15 @@ typedef enum {
@interface DDFileLogger : DDAbstractLogger <DDLogger>
{
- __strong id <DDLogFileManager> logFileManager;
-
- DDLogFileInfo *currentLogFileInfo;
- NSFileHandle *currentLogFileHandle;
-
- dispatch_source_t rollingTimer;
-
- unsigned long long maximumFileSize;
- NSTimeInterval rollingFrequency;
+ __strong id <DDLogFileManager> logFileManager;
+
+ DDLogFileInfo *currentLogFileInfo;
+ NSFileHandle *currentLogFileHandle;
+
+ dispatch_source_t rollingTimer;
+
+ unsigned long long maximumFileSize;
+ NSTimeInterval rollingFrequency;
}
- (id)init;
@@ -266,15 +266,15 @@ typedef enum {
**/
@interface DDLogFileInfo : NSObject
{
- __strong NSString *filePath;
- __strong NSString *fileName;
-
- __strong NSDictionary *fileAttributes;
-
- __strong NSDate *creationDate;
- __strong NSDate *modificationDate;
-
- unsigned long long fileSize;
+ __strong NSString *filePath;
+ __strong NSString *fileName;
+
+ __strong NSDictionary *fileAttributes;
+
+ __strong NSDate *creationDate;
+ __strong NSDate *modificationDate;
+
+ unsigned long long fileSize;
}
@property (strong, nonatomic, readonly) NSString *filePath;
View
1,700 Lumberjack/DDFileLogger.m
@@ -59,28 +59,28 @@ @implementation DDLogFileManagerDefault
- (id)init
{
- return [self initWithLogsDirectory:nil];
+ return [self initWithLogsDirectory:nil];
}
- (instancetype)initWithLogsDirectory:(NSString *)aLogsDirectory
{
- if ((self = [super init]))
- {
- maximumNumberOfLogFiles = DEFAULT_LOG_MAX_NUM_LOG_FILES;
-
- if (aLogsDirectory)
- _logsDirectory = [aLogsDirectory copy];
- else
- _logsDirectory = [[self defaultLogsDirectory] copy];
-
- NSKeyValueObservingOptions kvoOptions = NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew;
-
- [self addObserver:self forKeyPath:NSStringFromSelector(@selector(maximumNumberOfLogFiles)) options:kvoOptions context:nil];
-
- NSLogVerbose(@"DDFileLogManagerDefault: logsDirectory:\n%@", [self logsDirectory]);
- NSLogVerbose(@"DDFileLogManagerDefault: sortedLogFileNames:\n%@", [self sortedLogFileNames]);
- }
- return self;
+ if ((self = [super init]))
+ {
+ maximumNumberOfLogFiles = DEFAULT_LOG_MAX_NUM_LOG_FILES;
+
+ if (aLogsDirectory)
+ _logsDirectory = [aLogsDirectory copy];
+ else
+ _logsDirectory = [[self defaultLogsDirectory] copy];
+
+ NSKeyValueObservingOptions kvoOptions = NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew;
+
+ [self addObserver:self forKeyPath:NSStringFromSelector(@selector(maximumNumberOfLogFiles)) options:kvoOptions context:nil];
+
+ NSLogVerbose(@"DDFileLogManagerDefault: logsDirectory:\n%@", [self logsDirectory]);
+ NSLogVerbose(@"DDFileLogManagerDefault: sortedLogFileNames:\n%@", [self sortedLogFileNames]);
+ }
+ return self;
}
- (void)dealloc
@@ -103,24 +103,24 @@ - (void)observeValueForKeyPath:(NSString *)keyPath
change:(NSDictionary *)change
context:(void *)context
{
- NSNumber *old = [change objectForKey:NSKeyValueChangeOldKey];
- NSNumber *new = [change objectForKey:NSKeyValueChangeNewKey];
-
- if ([old isEqual:new])
- {
- // No change in value - don't bother with any processing.
- return;
- }
-
- if ([keyPath isEqualToString:@"maximumNumberOfLogFiles"])
- {
- NSLogInfo(@"DDFileLogManagerDefault: Responding to configuration change: maximumNumberOfLogFiles");
-
- dispatch_async([DDLog loggingQueue], ^{ @autoreleasepool {
-
- [self deleteOldLogFiles];
- }});
- }
+ NSNumber *old = [change objectForKey:NSKeyValueChangeOldKey];
+ NSNumber *new = [change objectForKey:NSKeyValueChangeNewKey];
+
+ if ([old isEqual:new])
+ {
+ // No change in value - don't bother with any processing.
+ return;
+ }
+
+ if ([keyPath isEqualToString:@"maximumNumberOfLogFiles"])
+ {
+ NSLogInfo(@"DDFileLogManagerDefault: Responding to configuration change: maximumNumberOfLogFiles");
+
+ dispatch_async([DDLog loggingQueue], ^{ @autoreleasepool {
+
+ [self deleteOldLogFiles];
+ }});
+ }
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -132,55 +132,55 @@ - (void)observeValueForKeyPath:(NSString *)keyPath
**/
- (void)deleteOldLogFiles
{
- NSLogVerbose(@"DDLogFileManagerDefault: deleteOldLogFiles");
-
- NSUInteger maxNumLogFiles = self.maximumNumberOfLogFiles;
- if (maxNumLogFiles == 0)
- {
- // Unlimited - don't delete any log files
- return;
- }
-
- NSArray *sortedLogFileInfos = [self sortedLogFileInfos];
-
- // Do we consider the first file?
- // We are only supposed to be deleting archived files.
- // In most cases, the first file is likely the log file that is currently being written to.
- // So in most cases, we do not want to consider this file for deletion.
-
- NSUInteger count = [sortedLogFileInfos count];
- BOOL excludeFirstFile = NO;
-
- if (count > 0)
- {
- DDLogFileInfo *logFileInfo = [sortedLogFileInfos objectAtIndex:0];
-
- if (!logFileInfo.isArchived)
- {
- excludeFirstFile = YES;
- }
- }
-
- NSArray *sortedArchivedLogFileInfos;
- if (excludeFirstFile)
- {
- count--;
- sortedArchivedLogFileInfos = [sortedLogFileInfos subarrayWithRange:NSMakeRange(1, count)];
- }
- else
- {
- sortedArchivedLogFileInfos = sortedLogFileInfos;
- }
-
- NSUInteger i;
- for (i = maxNumLogFiles; i < count; i++)
- {
- DDLogFileInfo *logFileInfo = [sortedArchivedLogFileInfos objectAtIndex:i];
-
- NSLogInfo(@"DDLogFileManagerDefault: Deleting file: %@", logFileInfo.fileName);
-
- [[NSFileManager defaultManager] removeItemAtPath:logFileInfo.filePath error:nil];
- }
+ NSLogVerbose(@"DDLogFileManagerDefault: deleteOldLogFiles");
+
+ NSUInteger maxNumLogFiles = self.maximumNumberOfLogFiles;
+ if (maxNumLogFiles == 0)
+ {
+ // Unlimited - don't delete any log files
+ return;
+ }
+
+ NSArray *sortedLogFileInfos = [self sortedLogFileInfos];
+
+ // Do we consider the first file?
+ // We are only supposed to be deleting archived files.
+ // In most cases, the first file is likely the log file that is currently being written to.
+ // So in most cases, we do not want to consider this file for deletion.
+
+ NSUInteger count = [sortedLogFileInfos count];
+ BOOL excludeFirstFile = NO;
+
+ if (count > 0)
+ {
+ DDLogFileInfo *logFileInfo = [sortedLogFileInfos objectAtIndex:0];
+
+ if (!logFileInfo.isArchived)
+ {
+ excludeFirstFile = YES;
+ }
+ }
+
+ NSArray *sortedArchivedLogFileInfos;
+ if (excludeFirstFile)
+ {
+ count--;
+ sortedArchivedLogFileInfos = [sortedLogFileInfos subarrayWithRange:NSMakeRange(1, count)];
+ }
+ else
+ {
+ sortedArchivedLogFileInfos = sortedLogFileInfos;
+ }
+
+ NSUInteger i;
+ for (i = maxNumLogFiles; i < count; i++)
+ {
+ DDLogFileInfo *logFileInfo = [sortedArchivedLogFileInfos objectAtIndex:i];
+
+ NSLogInfo(@"DDLogFileManagerDefault: Deleting file: %@", logFileInfo.fileName);
+
+ [[NSFileManager defaultManager] removeItemAtPath:logFileInfo.filePath error:nil];
+ }
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -194,64 +194,64 @@ - (void)deleteOldLogFiles
- (NSString *)defaultLogsDirectory
{
#if TARGET_OS_IPHONE
- NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
- NSString *baseDir = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;
- NSString *logsDirectory = [baseDir stringByAppendingPathComponent:@"Logs"];
+ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
+ NSString *baseDir = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;
+ NSString *logsDirectory = [baseDir stringByAppendingPathComponent:@"Logs"];
#else
- NSString *appName = [[NSProcessInfo processInfo] processName];
- NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
- NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : NSTemporaryDirectory();
- NSString *logsDirectory = [[basePath stringByAppendingPathComponent:@"Logs"] stringByAppendingPathComponent:appName];
+ NSString *appName = [[NSProcessInfo processInfo] processName];
+ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
+ NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : NSTemporaryDirectory();
+ NSString *logsDirectory = [[basePath stringByAppendingPathComponent:@"Logs"] stringByAppendingPathComponent:appName];
#endif
- return logsDirectory;
+ return logsDirectory;
}
- (NSString *)logsDirectory
{
- // We could do this check once, during initalization, and not bother again.
- // But this way the code continues to work if the directory gets deleted while the code is running.
-
- if (![[NSFileManager defaultManager] fileExistsAtPath:_logsDirectory])
- {
- NSError *err = nil;
- if (![[NSFileManager defaultManager] createDirectoryAtPath:_logsDirectory
- withIntermediateDirectories:YES attributes:nil error:&err])
- {
- NSLogError(@"DDFileLogManagerDefault: Error creating logsDirectory: %@", err);
- }
- }
-
- return _logsDirectory;
+ // We could do this check once, during initalization, and not bother again.
+ // But this way the code continues to work if the directory gets deleted while the code is running.
+
+ if (![[NSFileManager defaultManager] fileExistsAtPath:_logsDirectory])
+ {
+ NSError *err = nil;
+ if (![[NSFileManager defaultManager] createDirectoryAtPath:_logsDirectory
+ withIntermediateDirectories:YES attributes:nil error:&err])
+ {
+ NSLogError(@"DDFileLogManagerDefault: Error creating logsDirectory: %@", err);
+ }
+ }
+
+ return _logsDirectory;
}
- (BOOL)isLogFile:(NSString *)fileName
{
- // A log file has a name like "log-<uuid>.txt", where <uuid> is a HEX-string of 6 characters.
- //
- // For example: log-DFFE99.txt
-
- BOOL hasProperPrefix = [fileName hasPrefix:@"log-"];
-
- BOOL hasProperLength = [fileName length] >= 10;
-
-
- if (hasProperPrefix && hasProperLength)
- {
- NSCharacterSet *hexSet = [NSCharacterSet characterSetWithCharactersInString:@"0123456789ABCDEF"];
-
- NSString *hex = [fileName substringWithRange:NSMakeRange(4, 6)];
- NSString *nohex = [hex stringByTrimmingCharactersInSet:hexSet];
-
- if ([nohex length] == 0)
- {
- return YES;
- }
- }
-
- return NO;
+ // A log file has a name like "log-<uuid>.txt", where <uuid> is a HEX-string of 6 characters.
+ //
+ // For example: log-DFFE99.txt
+
+ BOOL hasProperPrefix = [fileName hasPrefix:@"log-"];
+
+ BOOL hasProperLength = [fileName length] >= 10;
+
+
+ if (hasProperPrefix && hasProperLength)
+ {
+ NSCharacterSet *hexSet = [NSCharacterSet characterSetWithCharactersInString:@"0123456789ABCDEF"];
+
+ NSString *hex = [fileName substringWithRange:NSMakeRange(4, 6)];
+ NSString *nohex = [hex stringByTrimmingCharactersInSet:hexSet];
+
+ if ([nohex length] == 0)
+ {
+ return YES;
+ }
+ }
+
+ return NO;
}
/**
@@ -260,24 +260,24 @@ - (BOOL)isLogFile:(NSString *)fileName
**/
- (NSArray *)unsortedLogFilePaths
{
- NSString *logsDirectory = [self logsDirectory];
- NSArray *fileNames = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:logsDirectory error:nil];
-
- NSMutableArray *unsortedLogFilePaths = [NSMutableArray arrayWithCapacity:[fileNames count]];
-
- for (NSString *fileName in fileNames)
- {
- // Filter out any files that aren't log files. (Just for extra safety)
-
- if ([self isLogFile:fileName])
- {
- NSString *filePath = [logsDirectory stringByAppendingPathComponent:fileName];
-
- [unsortedLogFilePaths addObject:filePath];
- }
- }
-
- return unsortedLogFilePaths;
+ NSString *logsDirectory = [self logsDirectory];
+ NSArray *fileNames = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:logsDirectory error:nil];
+
+ NSMutableArray *unsortedLogFilePaths = [NSMutableArray arrayWithCapacity:[fileNames count]];
+
+ for (NSString *fileName in fileNames)
+ {
+ // Filter out any files that aren't log files. (Just for extra safety)
+
+ if ([self isLogFile:fileName])
+ {
+ NSString *filePath = [logsDirectory stringByAppendingPathComponent:fileName];
+
+ [unsortedLogFilePaths addObject:filePath];
+ }
+ }
+
+ return unsortedLogFilePaths;
}
/**
@@ -286,16 +286,16 @@ - (NSArray *)unsortedLogFilePaths
**/
- (NSArray *)unsortedLogFileNames
{
- NSArray *unsortedLogFilePaths = [self unsortedLogFilePaths];
-
- NSMutableArray *unsortedLogFileNames = [NSMutableArray arrayWithCapacity:[unsortedLogFilePaths count]];
-
- for (NSString *filePath in unsortedLogFilePaths)
- {
- [unsortedLogFileNames addObject:[filePath lastPathComponent]];
- }
-
- return unsortedLogFileNames;
+ NSArray *unsortedLogFilePaths = [self unsortedLogFilePaths];
+
+ NSMutableArray *unsortedLogFileNames = [NSMutableArray arrayWithCapacity:[unsortedLogFilePaths count]];
+
+ for (NSString *filePath in unsortedLogFilePaths)
+ {
+ [unsortedLogFileNames addObject:[filePath lastPathComponent]];
+ }
+
+ return unsortedLogFileNames;
}
/**
@@ -305,18 +305,18 @@ - (NSArray *)unsortedLogFileNames
**/
- (NSArray *)unsortedLogFileInfos
{
- NSArray *unsortedLogFilePaths = [self unsortedLogFilePaths];
-
- NSMutableArray *unsortedLogFileInfos = [NSMutableArray arrayWithCapacity:[unsortedLogFilePaths count]];
-
- for (NSString *filePath in unsortedLogFilePaths)
- {
- DDLogFileInfo *logFileInfo = [[DDLogFileInfo alloc] initWithFilePath:filePath];
-
- [unsortedLogFileInfos addObject:logFileInfo];
- }
-
- return unsortedLogFileInfos;
+ NSArray *unsortedLogFilePaths = [self unsortedLogFilePaths];
+
+ NSMutableArray *unsortedLogFileInfos = [NSMutableArray arrayWithCapacity:[unsortedLogFilePaths count]];
+
+ for (NSString *filePath in unsortedLogFilePaths)
+ {
+ DDLogFileInfo *logFileInfo = [[DDLogFileInfo alloc] initWithFilePath:filePath];
+
+ [unsortedLogFileInfos addObject:logFileInfo];
+ }
+
+ return unsortedLogFileInfos;
}
/**
@@ -326,16 +326,16 @@ - (NSArray *)unsortedLogFileInfos
**/
- (NSArray *)sortedLogFilePaths
{
- NSArray *sortedLogFileInfos = [self sortedLogFileInfos];
-
- NSMutableArray *sortedLogFilePaths = [NSMutableArray arrayWithCapacity:[sortedLogFileInfos count]];
-
- for (DDLogFileInfo *logFileInfo in sortedLogFileInfos)
- {
- [sortedLogFilePaths addObject:[logFileInfo filePath]];
- }
-
- return sortedLogFilePaths;
+ NSArray *sortedLogFileInfos = [self sortedLogFileInfos];
+
+ NSMutableArray *sortedLogFilePaths = [NSMutableArray arrayWithCapacity:[sortedLogFileInfos count]];
+
+ for (DDLogFileInfo *logFileInfo in sortedLogFileInfos)
+ {
+ [sortedLogFilePaths addObject:[logFileInfo filePath]];
+ }
+
+ return sortedLogFilePaths;
}
/**
@@ -345,16 +345,16 @@ - (NSArray *)sortedLogFilePaths
**/
- (NSArray *)sortedLogFileNames
{
- NSArray *sortedLogFileInfos = [self sortedLogFileInfos];
-
- NSMutableArray *sortedLogFileNames = [NSMutableArray arrayWithCapacity:[sortedLogFileInfos count]];
-
- for (DDLogFileInfo *logFileInfo in sortedLogFileInfos)
- {
- [sortedLogFileNames addObject:[logFileInfo fileName]];
- }
-
- return sortedLogFileNames;
+ NSArray *sortedLogFileInfos = [self sortedLogFileInfos];
+
+ NSMutableArray *sortedLogFileNames = [NSMutableArray arrayWithCapacity:[sortedLogFileInfos count]];
+
+ for (DDLogFileInfo *logFileInfo in sortedLogFileInfos)
+ {
+ [sortedLogFileNames addObject:[logFileInfo fileName]];
+ }
+
+ return sortedLogFileNames;
}
/**
@@ -364,7 +364,7 @@ - (NSArray *)sortedLogFileNames
**/
- (NSArray *)sortedLogFileInfos
{
- return [[self unsortedLogFileInfos] sortedArrayUsingSelector:@selector(reverseCompareByCreationDate:)];
+ return [[self unsortedLogFileInfos] sortedArrayUsingSelector:@selector(reverseCompareByCreationDate:)];
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -411,8 +411,8 @@ - (NSString *)generateLogFileNameWithConvention:(DDLogFileNamingConvention)conve
break;
}
}
-
- return [NSString stringWithFormat:@"log-%@.txt", uniquePart];
+
+ return [NSString stringWithFormat:@"log-%@.txt", uniquePart];
}
/**
@@ -420,31 +420,31 @@ - (NSString *)generateLogFileNameWithConvention:(DDLogFileNamingConvention)conve
**/
- (NSString *)createNewLogFile
{
- // Generate a random log file name, and create the file (if there isn't a collision)
-
- NSString *logsDirectory = [self logsDirectory];
+ // Generate a random log file name, and create the file (if there isn't a collision)
+
+ NSString *logsDirectory = [self logsDirectory];
NSUInteger attempt = 1;
- do
- {
- NSString *fileName = [self generateLogFileNameWithConvention:self.fileNamingConvention attempt:attempt];
-
- NSString *filePath = [logsDirectory stringByAppendingPathComponent:fileName];
-
- if (![[NSFileManager defaultManager] fileExistsAtPath:filePath])
- {
- NSLogVerbose(@"DDLogFileManagerDefault: Creating new log file: %@", fileName);
-
- [[NSFileManager defaultManager] createFileAtPath:filePath contents:nil attributes:nil];
-
- // Since we just created a new log file, we may need to delete some old log files
- [self deleteOldLogFiles];
-
- return filePath;
- } else {
+ do
+ {
+ NSString *fileName = [self generateLogFileNameWithConvention:self.fileNamingConvention attempt:attempt];
+
+ NSString *filePath = [logsDirectory stringByAppendingPathComponent:fileName];
+
+ if (![[NSFileManager defaultManager] fileExistsAtPath:filePath])
+ {
+ NSLogVerbose(@"DDLogFileManagerDefault: Creating new log file: %@", fileName);
+
+ [[NSFileManager defaultManager] createFileAtPath:filePath contents:nil attributes:nil];
+
+ // Since we just created a new log file, we may need to delete some old log files
+ [self deleteOldLogFiles];
+
+ return filePath;
+ } else {
attempt++;
}
-
- } while(YES);
+
+ } while(YES);
}
@end
@@ -457,32 +457,32 @@ @implementation DDLogFileFormatterDefault
- (id)init
{
- return [self initWithDateFormatter:nil];
+ return [self initWithDateFormatter:nil];
}
- (instancetype)initWithDateFormatter:(NSDateFormatter *)aDateFormatter
{
- if ((self = [super init]))
- {
- if (aDateFormatter)
- {
- dateFormatter = aDateFormatter;
- }
- else
- {
- dateFormatter = [[NSDateFormatter alloc] init];
- [dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4]; // 10.4+ style
- [dateFormatter setDateFormat:@"yyyy/MM/dd HH:mm:ss:SSS"];
- }
- }
- return self;
+ if ((self = [super init]))
+ {
+ if (aDateFormatter)
+ {
+ dateFormatter = aDateFormatter;
+ }
+ else
+ {
+ dateFormatter = [[NSDateFormatter alloc] init];
+ [dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4]; // 10.4+ style
+ [dateFormatter setDateFormat:@"yyyy/MM/dd HH:mm:ss:SSS"];
+ }
+ }
+ return self;
}
- (NSString *)formatLogMessage:(DDLogMessage *)logMessage
{
- NSString *dateAndTime = [dateFormatter stringFromDate:(logMessage->timestamp)];
-
- return [NSString stringWithFormat:@"%@ %@", dateAndTime, logMessage->logMsg];
+ NSString *dateAndTime = [dateFormatter stringFromDate:(logMessage->timestamp)];
+
+ return [NSString stringWithFormat:@"%@ %@", dateAndTime, logMessage->logMsg];
}
@end
@@ -495,35 +495,35 @@ @implementation DDFileLogger
- (id)init
{
- DDLogFileManagerDefault *defaultLogFileManager = [[DDLogFileManagerDefault alloc] init];
-
- return [self initWithLogFileManager:defaultLogFileManager];
+ DDLogFileManagerDefault *defaultLogFileManager = [[DDLogFileManagerDefault alloc] init];
+
+ return [self initWithLogFileManager:defaultLogFileManager];
}
- (instancetype)initWithLogFileManager:(id <DDLogFileManager>)aLogFileManager
{
- if ((self = [super init]))
- {
- maximumFileSize = DEFAULT_LOG_MAX_FILE_SIZE;
- rollingFrequency = DEFAULT_LOG_ROLLING_FREQUENCY;
-
- logFileManager = aLogFileManager;
-
- formatter = [[DDLogFileFormatterDefault alloc] init];
- }
- return self;
+ if ((self = [super init]))
+ {
+ maximumFileSize = DEFAULT_LOG_MAX_FILE_SIZE;
+ rollingFrequency = DEFAULT_LOG_ROLLING_FREQUENCY;
+
+ logFileManager = aLogFileManager;
+
+ formatter = [[DDLogFileFormatterDefault alloc] init];
+ }
+ return self;
}
- (void)dealloc
{
- [currentLogFileHandle synchronizeFile];
- [currentLogFileHandle closeFile];
-
- if (rollingTimer)
- {
- dispatch_source_cancel(rollingTimer);
- rollingTimer = NULL;
- }
+ [currentLogFileHandle synchronizeFile];
+ [currentLogFileHandle closeFile];
+
+ if (rollingTimer)
+ {
+ dispatch_source_cancel(rollingTimer);
+ rollingTimer = NULL;
+ }
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -534,119 +534,119 @@ - (void)dealloc
- (unsigned long long)maximumFileSize
{
- __block unsigned long long result;
-
- dispatch_block_t block = ^{
- result = maximumFileSize;
- };
-
- // The design of this method is taken from the DDAbstractLogger implementation.
- // For extensive documentation please refer to the DDAbstractLogger implementation.
-
- // Note: The internal implementation MUST access the maximumFileSize variable directly,
- // This method is designed explicitly for external access.
- //
- // Using "self." syntax to go through this method will cause immediate deadlock.
- // This is the intended result. Fix it by accessing the ivar directly.
- // Great strides have been take to ensure this is safe to do. Plus it's MUCH faster.
-
- NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
- NSAssert(![self isOnInternalLoggerQueue], @"MUST access ivar directly, NOT via self.* syntax.");
-
- dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
-
- dispatch_sync(globalLoggingQueue, ^{
- dispatch_sync(loggerQueue, block);
- });
-
- return result;
+ __block unsigned long long result;
+
+ dispatch_block_t block = ^{
+ result = maximumFileSize;
+ };
+
+ // The design of this method is taken from the DDAbstractLogger implementation.
+ // For extensive documentation please refer to the DDAbstractLogger implementation.
+
+ // Note: The internal implementation MUST access the maximumFileSize variable directly,
+ // This method is designed explicitly for external access.
+ //
+ // Using "self." syntax to go through this method will cause immediate deadlock.
+ // This is the intended result. Fix it by accessing the ivar directly.
+ // Great strides have been take to ensure this is safe to do. Plus it's MUCH faster.
+
+ NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
+ NSAssert(![self isOnInternalLoggerQueue], @"MUST access ivar directly, NOT via self.* syntax.");
+
+ dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
+
+ dispatch_sync(globalLoggingQueue, ^{
+ dispatch_sync(loggerQueue, block);
+ });
+
+ return result;
}
- (void)setMaximumFileSize:(unsigned long long)newMaximumFileSize
{
- dispatch_block_t block = ^{ @autoreleasepool {
-
- maximumFileSize = newMaximumFileSize;
- [self maybeRollLogFileDueToSize];
-
- }};
-
- // The design of this method is taken from the DDAbstractLogger implementation.
- // For extensive documentation please refer to the DDAbstractLogger implementation.
-
- // Note: The internal implementation MUST access the maximumFileSize variable directly,
- // This method is designed explicitly for external access.
- //
- // Using "self." syntax to go through this method will cause immediate deadlock.
- // This is the intended result. Fix it by accessing the ivar directly.
- // Great strides have been take to ensure this is safe to do. Plus it's MUCH faster.
-
- NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
- NSAssert(![self isOnInternalLoggerQueue], @"MUST access ivar directly, NOT via self.* syntax.");
-
- dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
-
- dispatch_async(globalLoggingQueue, ^{
- dispatch_async(loggerQueue, block);
- });
+ dispatch_block_t block = ^{ @autoreleasepool {
+
+ maximumFileSize = newMaximumFileSize;
+ [self maybeRollLogFileDueToSize];
+
+ }};
+
+ // The design of this method is taken from the DDAbstractLogger implementation.
+ // For extensive documentation please refer to the DDAbstractLogger implementation.
+
+ // Note: The internal implementation MUST access the maximumFileSize variable directly,
+ // This method is designed explicitly for external access.
+ //
+ // Using "self." syntax to go through this method will cause immediate deadlock.
+ // This is the intended result. Fix it by accessing the ivar directly.
+ // Great strides have been take to ensure this is safe to do. Plus it's MUCH faster.
+
+ NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
+ NSAssert(![self isOnInternalLoggerQueue], @"MUST access ivar directly, NOT via self.* syntax.");
+
+ dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
+
+ dispatch_async(globalLoggingQueue, ^{
+ dispatch_async(loggerQueue, block);
+ });
}
- (NSTimeInterval)rollingFrequency
{
- __block NSTimeInterval result;
-
- dispatch_block_t block = ^{
- result = rollingFrequency;
- };
-
- // The design of this method is taken from the DDAbstractLogger implementation.
- // For extensive documentation please refer to the DDAbstractLogger implementation.
-
- // Note: The internal implementation should access the rollingFrequency variable directly,
- // This method is designed explicitly for external access.
- //
- // Using "self." syntax to go through this method will cause immediate deadlock.
- // This is the intended result. Fix it by accessing the ivar directly.
- // Great strides have been take to ensure this is safe to do. Plus it's MUCH faster.
-
- NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
- NSAssert(![self isOnInternalLoggerQueue], @"MUST access ivar directly, NOT via self.* syntax.");
-
- dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
-
- dispatch_sync(globalLoggingQueue, ^{
- dispatch_sync(loggerQueue, block);
- });
-
- return result;
+ __block NSTimeInterval result;
+
+ dispatch_block_t block = ^{
+ result = rollingFrequency;
+ };
+
+ // The design of this method is taken from the DDAbstractLogger implementation.
+ // For extensive documentation please refer to the DDAbstractLogger implementation.
+
+ // Note: The internal implementation should access the rollingFrequency variable directly,
+ // This method is designed explicitly for external access.
+ //
+ // Using "self." syntax to go through this method will cause immediate deadlock.
+ // This is the intended result. Fix it by accessing the ivar directly.
+ // Great strides have been take to ensure this is safe to do. Plus it's MUCH faster.
+
+ NSAssert(![self isOnGlobalLoggingQueue], @"Core architecture requirement failure");
+ NSAssert(![self isOnInternalLoggerQueue], @"MUST access ivar directly, NOT via self.* syntax.");
+
+ dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
+
+ dispatch_sync(globalLoggingQueue, ^{
+ dispatch_sync(loggerQueue, block);
+ });
+
+ return result;
}
- (void)setRollingFrequency:(NSTimeInterval)newRollingFrequency
{
- dispatch_block_t block = ^{ @autoreleasepool {
-
- rollingFrequency = newRollingFrequency;
- [self maybeRollLogFileDueToAge];