Skip to content

Commit

Permalink
Merging latest changes from CocoaLumberjack project
Browse files Browse the repository at this point in the history
  • Loading branch information
robbiehanson committed Mar 28, 2013
1 parent d94f4ef commit e15589e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 87 deletions.
34 changes: 4 additions & 30 deletions Vendor/CocoaLumberjack/DDAbstractDatabaseLogger.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,6 @@
#warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
#endif

/**
* Does ARC support support GCD objects?
* It does if the minimum deployment target is iOS 6+ or Mac OS X 10.8+
**/
#if TARGET_OS_IPHONE

// Compiling for iOS

#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000 // iOS 6.0 or later
#define NEEDS_DISPATCH_RETAIN_RELEASE 0
#else // iOS 5.X or earlier
#define NEEDS_DISPATCH_RETAIN_RELEASE 1
#endif

#else

// Compiling for Mac OS X

#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 // Mac OS X 10.8 or later
#define NEEDS_DISPATCH_RETAIN_RELEASE 0
#else
#define NEEDS_DISPATCH_RETAIN_RELEASE 1 // Mac OS X 10.7 or earlier
#endif

#endif

@interface DDAbstractDatabaseLogger ()
- (void)destroySaveTimer;
- (void)destroyDeleteTimer;
Expand Down Expand Up @@ -147,7 +121,7 @@ - (void)destroySaveTimer
dispatch_resume(saveTimer);
saveTimerSuspended = NO;
}
#if NEEDS_DISPATCH_RETAIN_RELEASE
#if !OS_OBJECT_USE_OBJC
dispatch_release(saveTimer);
#endif
saveTimer = NULL;
Expand All @@ -158,7 +132,7 @@ - (void)updateAndResumeSaveTimer
{
if ((saveTimer != NULL) && (saveInterval > 0.0) && (unsavedTime > 0.0))
{
uint64_t interval = saveInterval * NSEC_PER_SEC;
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);
Expand Down Expand Up @@ -192,7 +166,7 @@ - (void)destroyDeleteTimer
if (deleteTimer)
{
dispatch_source_cancel(deleteTimer);
#if NEEDS_DISPATCH_RETAIN_RELEASE
#if !OS_OBJECT_USE_OBJC
dispatch_release(deleteTimer);
#endif
deleteTimer = NULL;
Expand All @@ -203,7 +177,7 @@ - (void)updateDeleteTimer
{
if ((deleteTimer != NULL) && (deleteInterval > 0.0) && (maxAge > 0.0))
{
uint64_t interval = deleteInterval * NSEC_PER_SEC;
uint64_t interval = (uint64_t)(deleteInterval * NSEC_PER_SEC);
dispatch_time_t startTime;

if (lastDeleteTime > 0)
Expand Down
29 changes: 2 additions & 27 deletions Vendor/CocoaLumberjack/DDFileLogger.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,6 @@
#warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
#endif

// Does ARC support support GCD objects?
// It does if the minimum deployment target is iOS 6+ or Mac OS X 10.8+

#if TARGET_OS_IPHONE

// Compiling for iOS

#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000 // iOS 6.0 or later
#define NEEDS_DISPATCH_RETAIN_RELEASE 0
#else // iOS 5.X or earlier
#define NEEDS_DISPATCH_RETAIN_RELEASE 1
#endif

#else

// Compiling for Mac OS X

#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 // Mac OS X 10.8 or later
#define NEEDS_DISPATCH_RETAIN_RELEASE 0
#else
#define NEEDS_DISPATCH_RETAIN_RELEASE 1 // Mac OS X 10.7 or earlier
#endif

#endif

// We probably shouldn't be using DDLog() statements within the DDLog implementation.
// But we still want to leave our log statements for any future debugging,
// and to allow other developers to trace the implementation (which is a great learning tool).
Expand Down Expand Up @@ -674,14 +649,14 @@ - (void)scheduleTimerToRollLogFileDueToAge

}});

#if NEEDS_DISPATCH_RETAIN_RELEASE
#if !OS_OBJECT_USE_OBJC
dispatch_source_t theRollingTimer = rollingTimer;
dispatch_source_set_cancel_handler(rollingTimer, ^{
dispatch_release(theRollingTimer);
});
#endif

uint64_t delay = [logFileRollingDate timeIntervalSinceNow] * NSEC_PER_SEC;
uint64_t delay = (uint64_t)([logFileRollingDate timeIntervalSinceNow] * NSEC_PER_SEC);
dispatch_time_t fireTime = dispatch_time(DISPATCH_TIME_NOW, delay);

dispatch_source_set_timer(rollingTimer, fireTime, DISPATCH_TIME_FOREVER, 1.0);
Expand Down
2 changes: 1 addition & 1 deletion Vendor/CocoaLumberjack/DDLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ NSString *DDExtractFileNameWithoutExtension(const char *filePath, BOOL copy);

enum {
DDLogMessageCopyFile = 1 << 0,
DDLogMessageCopyFunction = 1 << 1,
DDLogMessageCopyFunction = 1 << 1
};
typedef int DDLogMessageOptions;

Expand Down
33 changes: 4 additions & 29 deletions Vendor/CocoaLumberjack/DDLog.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,6 @@
#warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
#endif

// Does ARC support support GCD objects?
// It does if the minimum deployment target is iOS 6+ or Mac OS X 10.8+

#if TARGET_OS_IPHONE

// Compiling for iOS

#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000 // iOS 6.0 or later
#define NEEDS_DISPATCH_RETAIN_RELEASE 0
#else // iOS 5.X or earlier
#define NEEDS_DISPATCH_RETAIN_RELEASE 1
#endif

#else

// Compiling for Mac OS X

#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 // Mac OS X 10.8 or later
#define NEEDS_DISPATCH_RETAIN_RELEASE 0
#else
#define NEEDS_DISPATCH_RETAIN_RELEASE 1 // Mac OS X 10.7 or earlier
#endif

#endif

// We probably shouldn't be using DDLog() statements within the DDLog implementation.
// But we still want to leave our log statements for any future debugging,
// and to allow other developers to trace the implementation (which is a great learning tool).
Expand Down Expand Up @@ -805,7 +780,7 @@ - (id)initWithLogger:(id <DDLogger>)aLogger loggerQueue:(dispatch_queue_t)aLogge

if (aLoggerQueue) {
loggerQueue = aLoggerQueue;
#if NEEDS_DISPATCH_RETAIN_RELEASE
#if !OS_OBJECT_USE_OBJC
dispatch_retain(loggerQueue);
#endif
}
Expand All @@ -820,7 +795,7 @@ + (DDLoggerNode *)nodeWithLogger:(id <DDLogger>)logger loggerQueue:(dispatch_que

- (void)dealloc
{
#if NEEDS_DISPATCH_RETAIN_RELEASE
#if !OS_OBJECT_USE_OBJC
if (loggerQueue) dispatch_release(loggerQueue);
#endif
}
Expand Down Expand Up @@ -871,7 +846,7 @@ - (id)initWithLogMsg:(NSString *)msg
file = (char *)aFile;

if (options & DDLogMessageCopyFunction)
file = dd_str_copy(aFunction);
function = dd_str_copy(aFunction);
else
function = (char *)aFunction;

Expand Down Expand Up @@ -977,7 +952,7 @@ - (id)init

- (void)dealloc
{
#if NEEDS_DISPATCH_RETAIN_RELEASE
#if !OS_OBJECT_USE_OBJC
if (loggerQueue) dispatch_release(loggerQueue);
#endif
}
Expand Down

0 comments on commit e15589e

Please sign in to comment.