diff --git a/AWSAppSyncClient/AWSAppSyncClient.swift b/AWSAppSyncClient/AWSAppSyncClient.swift index 0f547d99..ec5a791f 100644 --- a/AWSAppSyncClient/AWSAppSyncClient.swift +++ b/AWSAppSyncClient/AWSAppSyncClient.swift @@ -6,6 +6,7 @@ import Foundation import AWSCore +import AppSyncRealTimeClient public typealias SubscriptionResultHandler = (_ result: GraphQLResult?, _ transaction: ApolloStore.ReadWriteTransaction?, _ error: Error?) -> Void @@ -119,6 +120,8 @@ public class AWSAppSyncClient { name: .appSyncReachabilityChanged, object: nil) + AppSyncRealTimeClient.logLevel = AppSyncLogHelper.subscriptionLogLevel + try AWSAppSyncClient.prefixTrackerQueue.sync { if appSyncConfig.cacheConfiguration?.usePrefix ?? false { let prefixTrackerKey = appSyncConfig.cacheConfiguration?.prefix ?? "" diff --git a/AWSAppSyncClient/Internal/AppSyncLogHelper.swift b/AWSAppSyncClient/Internal/AppSyncLogHelper.swift index 20e08e00..d22b3e39 100644 --- a/AWSAppSyncClient/Internal/AppSyncLogHelper.swift +++ b/AWSAppSyncClient/Internal/AppSyncLogHelper.swift @@ -6,6 +6,7 @@ import Foundation import AWSCore +import AppSyncRealTimeClient struct AppSyncLogHelper { @@ -19,7 +20,6 @@ struct AppSyncLogHelper { file: String, function: String, line: UInt) { - AWSDDLog.log(asynchronous: true, level: AWSDDLog.sharedInstance.logLevel, flag: flag, @@ -31,4 +31,21 @@ struct AppSyncLogHelper { format: message, arguments: getVaList([])) } + + static var subscriptionLogLevel: AppSyncRealTimeClient.LogLevel { + switch AWSDDLog.sharedInstance.logLevel { + case .off, .error: + return .error + case .warning: + return .warn + case .info: + return .info + case .debug: + return .debug + case .verbose, .all: + return .verbose + @unknown default: + return .error + } + } } diff --git a/AWSAppSyncTestCommon/AppSyncClientTestHelper.swift b/AWSAppSyncTestCommon/AppSyncClientTestHelper.swift index 1e103c08..42cbc4f4 100644 --- a/AWSAppSyncTestCommon/AppSyncClientTestHelper.swift +++ b/AWSAppSyncTestCommon/AppSyncClientTestHelper.swift @@ -112,9 +112,8 @@ public class AppSyncClientTestHelper: NSObject { throw TestHelperError.setupError(AppSyncClientTestHelper.testSetupErrorMessage) } - AWSDDLog.sharedInstance.logLevel = .error - AWSDDLog.add(AWSDDTTYLogger.sharedInstance) - + AWSDDLog.sharedInstance.add(AWSDDTTYLogger.sharedInstance) + let appSyncConfig = try AppSyncClientTestHelper.makeAppSyncConfiguration( for: authenticationType, testConfiguration: resolvedTestConfiguration,