Here is an example of how to add a logger with levels to an app. So instead of going

NSLog(@"Found Match %@.", info);

You can go


LogD(@"Found Match %@.", info);
LogE(@"Could not find.");
[/code]

Remote.h

typedef NS_ENUM(NSUInteger, RemoteLogLevel) {
  /// Do not log at all.
  RemoteLogLevelNone = 0,
  /// Log debug, info and error messages.
  RemoteLogLevelDebug = 1,
  /// Log info and error messages.
  RemoteLogLevelInfo = 2,
  /// Log only error messages.
  RemoteLogLevelError = 3,
};

* @param logLevel The lowest severity to log to console.

- (instancetype)initWithLogLevel:(RemoteLogLevel)logLevel NS_DESIGNATED_INITIALIZER;

Remote.m

- (instancetype)initWithLogLevel:(RemoteLogLevel)logLevel
{
  self = [super init];

  if (self) {
    [RemoteLogger sharedLogger].logLevel = logLevel;
  }

  return self;
}

- (void)connect
{
  LogI(@"Connecting...");
  [self.transport connect];
}

RemoteLogger.h

NS_ASSUME_NONNULL_BEGIN

#define LogD(fmt,...) [[RemoteLogger sharedLogger] logMessage:[NSString stringWithFormat:(fmt), ##__VA_ARGS__] \
level:RemoteLogLevelDebug];

#define LogI(fmt,...) [[RemoteLogger sharedLogger] logMessage:[NSString stringWithFormat:(fmt), ##__VA_ARGS__] \
level:RemoteLogLevelInfo];

#define LogE(fmt,...) [[RemoteLogger sharedLogger] logMessage:[NSString stringWithFormat:(fmt), ##__VA_ARGS__] \
level:RemoteLogLevelError];

/// The @c RemoteLogger is a singleton that handles logging messages to console, with different log levels.
@interface RemoteLogger : NSObject

/// Returns the shared instance of the logger.
+ (instancetype)sharedLogger;

/// The lowest log level that the logger will log to console.
@property (nonatomic, assign, readwrite) RemoteLogLevel logLevel;

/**
* Logs the message at the given level.
*
* @param message The message to log.
* @param level The severity of the message.
*/
- (void)logMessage:(NSString *)message level:(RemoteLogLevel)level;

@end
NS_ASSUME_NONNULL_END

RemoteLogger.h

#import "RemoteLogger.h"

@implementation RemoteLogger

+ (instancetype)sharedLogger
{
  static RemoteLogger *sharedLogger = nil;
  static dispatch_once_t onceToken;
  dispatch_once(&onceToken, ^{
  sharedLogger = [self new];
  sharedLogger.logLevel = RemoteLogLevelInfo;
});
return sharedLogger;
}

- (void)logMessage:(NSString *)message level:(RemoteLogLevel)level
{
  if (level < self.logLevel) {
    return;
  }

  NSLog(@"Remote: %@", message);
}

@end