diff --git a/Configs/Module-Debug.xcconfig b/Configs/Module-Debug.xcconfig index dd4e5682b..e50d1b275 100644 --- a/Configs/Module-Debug.xcconfig +++ b/Configs/Module-Debug.xcconfig @@ -23,6 +23,9 @@ ENABLE_NS_ASSERTIONS = YES // When this setting is activated, the product will be built with options appropriate for running automated tests, such as making private interfaces accessible to the tests. ENABLE_TESTABILITY = YES +// Check for violations of nullability annotations in function calls, return statements, and assignments. +CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES + // Specifies the degree to which the generated code is optimized for speed and binary size. GCC_OPTIMIZATION_LEVEL = 0 diff --git a/Sources/CocoaLumberjack/DDFileLogger.m b/Sources/CocoaLumberjack/DDFileLogger.m index b18931a73..1a78724fd 100644 --- a/Sources/CocoaLumberjack/DDFileLogger.m +++ b/Sources/CocoaLumberjack/DDFileLogger.m @@ -1081,6 +1081,9 @@ - (DDLogFileInfo *)lt_currentLogFileInfo { @"Invalid log file manager! Responds neither to `-createNewLogFileWithError:` nor `-createNewLogFile`!"); currentLogFilePath = [_logFileManager createNewLogFile]; #pragma clang diagnostic pop + if (!currentLogFilePath) { + NSLogError(@"DDFileLogger: Failed to create new log file"); + } } // Use static factory method here, since it checks for nil (and is unavailable to Swift). _currentLogFileInfo = [DDLogFileInfo logFileWithPath:currentLogFilePath]; @@ -1325,6 +1328,8 @@ - (void)lt_logData:(NSData *)data { } @try { + NSFileHandle *handle = [self lt_currentLogFileHandle]; + if (implementsDeprecatedWillLog) { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" @@ -1334,7 +1339,6 @@ - (void)lt_logData:(NSData *)data { [self willLogMessage:_currentLogFileInfo]; } - NSFileHandle *handle = [self lt_currentLogFileHandle]; if (@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)) { __autoreleasing NSError *error = nil; BOOL success = [handle seekToEndReturningOffset:nil error:&error];