DDContextWhitelistFilterLogFormatter

Objective-C

@interface DDContextWhitelistFilterLogFormatter : NSObject <DDLogFormatter>

Swift

class DDContextWhitelistFilterLogFormatter : NSObject, DDLogFormatter

This class provides a log formatter that filters log statements from a logging context not on the whitelist.

A log formatter can be added to any logger to format and/or filter its output. You can learn more about log formatters here: Documentation/CustomFormatters.md

You can learn more about logging context’s here: Documentation/CustomContext.md

But here’s a quick overview / refresher:

Every log statement has a logging context. These come from the underlying logging macros defined in DDLog.h. The default logging context is zero. You can define multiple logging context’s for use in your application. For example, logically separate parts of your app each have a different logging context. Also 3rd party frameworks that make use of Lumberjack generally use their own dedicated logging context.

  • Designated default initializer

    Declaration

    Objective-C

    - (nonnull instancetype)init;

    Swift

    init()
  • Add a context to the whitelist

    Declaration

    Objective-C

    - (void)addToWhitelist:(NSInteger)loggingContext;

    Swift

    func add(toWhitelist loggingContext: Int)

    Parameters

    loggingContext

    the context

  • Remove context from whitelist

    Declaration

    Objective-C

    - (void)removeFromWhitelist:(NSInteger)loggingContext;

    Swift

    func remove(fromWhitelist loggingContext: Int)

    Parameters

    loggingContext

    the context

  • Return the whitelist

    Declaration

    Objective-C

    @property (nonatomic, copy, readonly) NSArray<NSNumber *> *_Nonnull whitelist;

    Swift

    var whitelist: [NSNumber] { get }
  • Check if a context is on the whitelist

    Declaration

    Objective-C

    - (BOOL)isOnWhitelist:(NSInteger)loggingContext;

    Swift

    func `is`(onWhitelist loggingContext: Int) -> Bool

    Parameters

    loggingContext

    the context