RLMLogger

Objective-C

@interface RLMLogger : NSObject

Swift

class RLMLogger : NSObject

RLMLogger is used for creating your own custom logging logic.

You can define your own logger creating an instance of RLMLogger and define the log function which will be invoked whenever there is a log message. Set this custom logger as you default logger using setDefaultLogger.

RLMLogger.defaultLogger = [[RLMLogger alloc] initWithLevel:RLMLogLevelDebug
                                           logFunction:^(RLMLogLevel level, NSString * message) {
    NSLog(@"Realm Log - %lu, %@", (unsigned long)level, message);
}];

Note

By default default log threshold level is RLMLogLevelInfo, and logging strings are output to Apple System Logger.
  • Gets the logging threshold level used by the logger.

    Declaration

    Objective-C

    @property (nonatomic) RLMLogLevel level;

    Swift

    var level: LogLevel { get set }
  • Creates a logger with the associated log level and the logic function to define your own logging logic.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithLevel:(RLMLogLevel)level
                              logFunction:(nonnull RLMLogFunction)logFunction;

    Swift

    init(level: LogLevel, logFunction: @escaping RLMLogFunction)

    Parameters

    level

    The log level to be set for the logger.

    logFunction

    The log function which will be invoked whenever there is a log message.

RLMLogger Default Logger API

  • The current default logger. When setting a logger as default, this logger will be used whenever information must be logged.

    Declaration

    Objective-C

    @property (class) NS_SWIFT_NAME(shared) RLMLogger *defaultLogger;

    Swift

    class var shared: RLMLogger { get set }