1 ////////////////////////////////////////////////////////////////////////////
3 // Copyright 2016 Realm Inc.
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
17 ////////////////////////////////////////////////////////////////////////////
19 #import <Foundation/Foundation.h>
21 #import "RLMSyncUtil.h"
23 @class RLMSyncSession;
25 /// An enum representing different levels of sync-related logging that can be configured.
26 typedef NS_ENUM(NSUInteger, RLMSyncLogLevel) {
27 /// Nothing will ever be logged.
29 /// Only fatal errors will be logged.
31 /// Only errors will be logged.
33 /// Warnings and errors will be logged.
35 /// Information about sync events will be logged. Fewer events will be logged in order to avoid overhead.
37 /// Information about sync events will be logged. More events will be logged than with `RLMSyncLogLevelInfo`.
38 RLMSyncLogLevelDetail,
39 /// Log information that can aid in debugging.
41 /// - warning: Will incur a measurable performance impact.
43 /// Log information that can aid in debugging. More events will be logged than with `RLMSyncLogLevelDebug`.
45 /// - warning: Will incur a measurable performance impact.
47 /// Log information that can aid in debugging. More events will be logged than with `RLMSyncLogLevelTrace`.
49 /// - warning: Will incur a measurable performance impact.
53 NS_ASSUME_NONNULL_BEGIN
55 /// A block type representing a block which can be used to report a sync-related error to the application. If the error
56 /// pertains to a specific session, that session will also be passed into the block.
57 typedef void(^RLMSyncErrorReportingBlock)(NSError *, RLMSyncSession * _Nullable);
60 A singleton manager which serves as a central point for sync-related configuration.
62 @interface RLMSyncManager : NSObject
65 A block which can optionally be set to report sync-related errors to your application.
67 Any error reported through this block will be of the `RLMSyncError` type, and marked
68 with the `RLMSyncErrorDomain` domain.
70 Errors reported through this mechanism are fatal, with several exceptions. Please consult
71 `RLMSyncError` for information about the types of errors that can be reported through
72 the block, and for for suggestions on handling recoverable error codes.
76 @property (nullable, nonatomic, copy) RLMSyncErrorReportingBlock errorHandler;
79 A reverse-DNS string uniquely identifying this application. In most cases this is automatically set by the SDK, and
80 does not have to be explicitly configured.
82 @property (nonatomic, copy) NSString *appID;
85 The logging threshold which newly opened synced Realms will use. Defaults to
86 `RLMSyncLogLevelInfo`.
88 Logging strings are output to Apple System Logger.
90 @warning This property must be set before any synced Realms are opened. Setting it after
91 opening any synced Realm will do nothing.
93 @property (nonatomic) RLMSyncLogLevel logLevel;
95 /// The sole instance of the singleton.
96 + (instancetype)sharedManager NS_REFINED_FOR_SWIFT;
99 - (instancetype)init __attribute__((unavailable("RLMSyncManager cannot be created directly")));
102 + (instancetype)new __attribute__((unavailable("RLMSyncManager cannot be created directly")));
104 NS_ASSUME_NONNULL_END