diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f348c4..55fe03d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,8 @@ - `- [GULKeychainStorage getObjectForKey:objectClass:accessGroup:]` - `- [GULKeychainStorage setObject:forKey:accessGroup:]` - `- [GULKeychainStorage removeObjectForKey:accessGroup:]` + - Update underlying GULLogger implementation from `asl` to `os_log`. + - Remove `GULLoggerEnableSTDERR` API. # 7.13.3 - Rename parameter placeholder in `GULSecureCoding` unarchiving API to avoid diff --git a/GoogleUtilities/Logger/GULLogger.m b/GoogleUtilities/Logger/GULLogger.m index 8a1c2be..af924cb 100644 --- a/GoogleUtilities/Logger/GULLogger.m +++ b/GoogleUtilities/Logger/GULLogger.m @@ -57,14 +57,6 @@ void GULLoggerInitialize(void) { }); } -void GULLoggerInitializeASL(void) { - GULLoggerInitialize(); -} - -void GULLoggerEnableSTDERR(void) { - // No-op -} - void GULLoggerForceDebug(void) { // We should enable debug mode if we're not running from App Store. if (![GULAppEnvironmentUtil isFromAppStore]) { @@ -180,38 +172,6 @@ void GULOSLogBasic(GULLoggerLevel level, }); } -void GULLogBasic(GULLoggerLevel level, - GULLoggerService service, - BOOL forceLog, - NSString *messageCode, - NSString *message, - va_list args_ptr) { - GULOSLogBasic(level, kGULLogSubsystem, service, forceLog, messageCode, message, args_ptr); -} - -/** - * Generates the logging functions using macros. - * - * Calling GULLogError({service}, @"I-XYZ000001", @"Configure %@ failed.", @"blah") shows: - * yyyy-mm-dd hh:mm:ss.SSS sender[PID] [{service}][I-XYZ000001] Configure blah failed. - * Calling GULLogDebug({service}, @"I-XYZ000001", @"Configure succeed.") shows: - * yyyy-mm-dd hh:mm:ss.SSS sender[PID] [{service}][I-XYZ000001] Configure succeed. - */ -#define GUL_LOGGING_FUNCTION(level) \ - void GULLog##level(GULLoggerService service, BOOL force, NSString *messageCode, \ - NSString *message, ...) { \ - va_list args_ptr; \ - va_start(args_ptr, message); \ - GULLogBasic(GULLoggerLevel##level, service, force, messageCode, message, args_ptr); \ - va_end(args_ptr); \ - } - -GUL_LOGGING_FUNCTION(Error) -GUL_LOGGING_FUNCTION(Warning) -GUL_LOGGING_FUNCTION(Notice) -GUL_LOGGING_FUNCTION(Info) -GUL_LOGGING_FUNCTION(Debug) - #undef GUL_LOGGING_FUNCTION /** diff --git a/GoogleUtilities/Logger/Public/GoogleUtilities/GULLogger.h b/GoogleUtilities/Logger/Public/GoogleUtilities/GULLogger.h index f4813ce..30cc800 100644 --- a/GoogleUtilities/Logger/Public/GoogleUtilities/GULLogger.h +++ b/GoogleUtilities/Logger/Public/GoogleUtilities/GULLogger.h @@ -31,27 +31,15 @@ typedef NSString *const GULLoggerService; extern "C" { #endif // __cplusplus -/// DEPRECATED; provide a relevant subsystem name rather than using default. +/// Used for other GoogleUtilities logging. extern NSString *const kGULLogSubsystem; /// Initialize GULLogger. extern void GULLoggerInitialize(void); -/// Initialize GULLogger. -/// -/// The Apple System Log (ASL) in Google Utilities Logger has been replaced by OSLog. -/// -/// DEPRECATED; simply calls its replacement `GULLoggerInitialize`. -extern void GULLoggerInitializeASL(void); - /// Override log level to Debug. void GULLoggerForceDebug(void); -/// Turn on logging to STDERR. -/// -/// DEPRECATED; this function is a no-op. -extern void GULLoggerEnableSTDERR(void); - /// Gets the current `GULLoggerLevel`. extern GULLoggerLevel GULGetLoggerLevel(void); @@ -102,66 +90,6 @@ extern void GULOSLogBasic(GULLoggerLevel level, #endif ); -/** - * Logs a message to the Xcode console and the device log. If running from AppStore, will - * not log any messages with a level higher than GULLoggerLevelNotice to avoid log spamming. - * (required) log level (one of the GULLoggerLevel enum values). - * (required) service name of type GULLoggerService. - * (required) message code starting with "I-" which means iOS, followed by a capitalized - * three-character service identifier and a six digit integer message ID that is unique - * within the service. - * An example of the message code is @"I-COR000001". - * (required) message string which can be a format string. - * (optional) variable arguments list obtained from calling va_start, used when message is a format - * string. - * - * DEPRECATED; replaced by `GULOSLogBasic`. - */ -extern void GULLogBasic(GULLoggerLevel level, - GULLoggerService service, - BOOL forceLog, - NSString *messageCode, - NSString *message, -// On 64-bit simulators, va_list is not a pointer, so cannot be marked nullable -// See: http://stackoverflow.com/q/29095469 -#if __LP64__ && TARGET_OS_SIMULATOR || TARGET_OS_OSX - va_list args_ptr -#else - va_list _Nullable args_ptr -#endif -); - -/** - * The following functions accept the following parameters in order: - * (required) service name of type GULLoggerService. - * (required) message code starting from "I-" which means iOS, followed by a capitalized - * three-character service identifier and a six digit integer message ID that is unique - * within the service. - * An example of the message code is @"I-COR000001". - * See go/firebase-log-proposal for details. - * (required) message string which can be a format string. - * (optional) the list of arguments to substitute into the format string. - * Example usage: - * GULLogError(kGULLoggerCore, @"I-COR000001", @"Configuration of %@ failed.", app.name); - * - * DEPRECATED; replaced by `GULOSLogError`, `GULOSLogWarning`, etc. - */ -extern void GULLogError( - GULLoggerService service, BOOL force, NSString *messageCode, NSString *message, ...) - NS_FORMAT_FUNCTION(4, 5) DEPRECATED_MSG_ATTRIBUTE("Replaced by `GULOSLogError`."); -extern void GULLogWarning( - GULLoggerService service, BOOL force, NSString *messageCode, NSString *message, ...) - NS_FORMAT_FUNCTION(4, 5) DEPRECATED_MSG_ATTRIBUTE("Replaced by `GULOSLogWarning`."); -extern void GULLogNotice( - GULLoggerService service, BOOL force, NSString *messageCode, NSString *message, ...) - NS_FORMAT_FUNCTION(4, 5) DEPRECATED_MSG_ATTRIBUTE("Replaced by `GULOSLogInfo`."); -extern void GULLogInfo( - GULLoggerService service, BOOL force, NSString *messageCode, NSString *message, ...) - NS_FORMAT_FUNCTION(4, 5) DEPRECATED_MSG_ATTRIBUTE("Replaced by `GULOSLogInfo`."); -extern void GULLogDebug( - GULLoggerService service, BOOL force, NSString *messageCode, NSString *message, ...) - NS_FORMAT_FUNCTION(4, 5) DEPRECATED_MSG_ATTRIBUTE("Replaced by `GULOSLogDebug`."); - /** * The following functions accept the following parameters in order: * (required) service name of type GULLoggerService. @@ -232,26 +160,6 @@ extern void GULOSLogDebug(NSString *subsystem, message:(NSString *)message arguments:(va_list)args; -/** - * Objective-C wrapper for GULLogBasic to allow weak linking to GULLogger - * (required) log level (one of the GULLoggerLevel enum values). - * (required) service name of type GULLoggerService. - * (required) message code starting with "I-" which means iOS, followed by a capitalized - * three-character service identifier and a six digit integer message ID that is unique - * within the service. - * An example of the message code is @"I-COR000001". - * (required) message string which can be a format string. - * (optional) variable arguments list obtained from calling va_start, used when message is a format - * string. - * - * DEPRECATED; replaced by `logWithLevel:subsystem:category:messageCode:message:arguments:`. - */ -+ (void)logWithLevel:(GULLoggerLevel)level - withService:(GULLoggerService)service - withCode:(NSString *)messageCode - withMessage:(NSString *)message - withArgs:(va_list)args; - @end NS_ASSUME_NONNULL_END diff --git a/GoogleUtilities/Tests/Unit/Logger/GULLoggerTest.m b/GoogleUtilities/Tests/Unit/Logger/GULLoggerTest.m index 42c2cc2..808e57b 100644 --- a/GoogleUtilities/Tests/Unit/Logger/GULLoggerTest.m +++ b/GoogleUtilities/Tests/Unit/Logger/GULLoggerTest.m @@ -140,64 +140,5 @@ - (void)testGULResetLogger_ResetsLoggerLevel { XCTAssertEqual(loggerLevel, GULLoggerLevelNotice); } -#pragma mark - Deprecated Functions - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - -- (void)testDeprecatedInitializeASL { - XCTAssertNoThrow(GULLoggerInitializeASL()); -} - -- (void)testDeprecatedEnableSTDERR { - XCTAssertNoThrow(GULLoggerEnableSTDERR()); -} - -- (void)testDeprecatedMessageCodeFormat { - // Valid case. - XCTAssertNoThrow(GULLogError(@"my service", NO, @"I-APP000001", @"Message.")); - - // An extra dash or missing dash should fail. - XCTAssertThrows(GULLogError(@"my service", NO, @"I-APP-000001", @"Message.")); - XCTAssertThrows(GULLogError(@"my service", NO, @"IAPP000001", @"Message.")); - - // Wrong number of digits should fail. - XCTAssertThrows(GULLogError(@"my service", NO, @"I-APP00001", @"Message.")); - XCTAssertThrows(GULLogError(@"my service", NO, @"I-APP0000001", @"Message.")); - - // Lowercase should fail. - XCTAssertThrows(GULLogError(@"my service", NO, @"I-app000001", @"Message.")); - - // nil or empty message code should fail. -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wnonnull" - XCTAssertThrows(GULLogError(@"my service", NO, nil, @"Message.")); -#pragma clang diagnostic pop - - XCTAssertThrows(GULLogError(@"my service", NO, @"", @"Message.")); - - // Android message code should fail. - XCTAssertThrows(GULLogError(@"my service", NO, @"A-APP000001", @"Message.")); -} - -- (void)testDeprecatedLoggerInterface { - XCTAssertNoThrow(GULLogError(@"my service", NO, kMessageCode, @"Message.")); - XCTAssertNoThrow(GULLogError(@"my service", NO, kMessageCode, @"Configure %@.", @"blah")); - - XCTAssertNoThrow(GULLogWarning(@"my service", NO, kMessageCode, @"Message.")); - XCTAssertNoThrow(GULLogWarning(@"my service", NO, kMessageCode, @"Configure %@.", @"blah")); - - XCTAssertNoThrow(GULLogNotice(@"my service", NO, kMessageCode, @"Message.")); - XCTAssertNoThrow(GULLogNotice(@"my service", NO, kMessageCode, @"Configure %@.", @"blah")); - - XCTAssertNoThrow(GULLogInfo(@"my service", NO, kMessageCode, @"Message.")); - XCTAssertNoThrow(GULLogInfo(@"my service", NO, kMessageCode, @"Configure %@.", @"blah")); - - XCTAssertNoThrow(GULLogDebug(@"my service", NO, kMessageCode, @"Message.")); - XCTAssertNoThrow(GULLogDebug(@"my service", NO, kMessageCode, @"Configure %@.", @"blah")); -} - -#pragma clang diagnostic pop - @end #endif