AWSDDLog

Objective-C


@interface AWSDDLog : NSObject

Swift

class AWSDDLog : NSObject, @unchecked Sendable

The main class, exposes all logging mechanisms, loggers, … For most of the users, this class is hidden behind the logging functions like AWSDDLogInfo

  • Returns the singleton AWSDDLog. The instance is used by AWSDDLog class methods.

    Declaration

    Objective-C

    @property (class, nonatomic, strong, readonly) AWSDDLog *_Nonnull sharedInstance;

    Swift

    class var sharedInstance: AWSDDLog { get }
  • Log level setting.

    Declaration

    Objective-C

    @property (nonatomic) AWSDDLogLevel logLevel;

    Swift

    var logLevel: AWSDDLogLevel { get set }
  • Provides access to the underlying logging queue. This may be helpful to Logger classes for things like thread synchronization.

    Declaration

    Objective-C

    @property (class, nonatomic, strong, readonly) dispatch_queue_t _Nonnull loggingQueue;

    Swift

    class var loggingQueue: DispatchQueue { get }
  • Logging Primitive.

    This method is used by the macros or logging functions. It is suggested you stick with the macros as they’re easier to use.

    Declaration

    Objective-C

    + (void)log:(BOOL)asynchronous
           level:(AWSDDLogLevel)level
            flag:(AWSDDLogFlag)flag
         context:(NSInteger)context
            file:(nonnull const char *)file
        function:(nullable const char *)function
            line:(NSUInteger)line
             tag:(nullable id)tag
          format:(nonnull NSString *)format, ...;

    Parameters

    asynchronous

    YES if the logging is done async, NO if you want to force sync

    level

    the log level

    flag

    the log flag

    context

    the context (if any is defined)

    file

    the current file

    function

    the current function

    line

    the current code line

    tag

    potential tag

    format

    the log format

  • Logging Primitive.

    This method is used by the macros or logging functions. It is suggested you stick with the macros as they’re easier to use.

    Declaration

    Objective-C

    - (void)log:(BOOL)asynchronous
           level:(AWSDDLogLevel)level
            flag:(AWSDDLogFlag)flag
         context:(NSInteger)context
            file:(nonnull const char *)file
        function:(nullable const char *)function
            line:(NSUInteger)line
             tag:(nullable id)tag
          format:(nonnull NSString *)format, ...;

    Parameters

    asynchronous

    YES if the logging is done async, NO if you want to force sync

    level

    the log level

    flag

    the log flag

    context

    the context (if any is defined)

    file

    the current file

    function

    the current function

    line

    the current code line

    tag

    potential tag

    format

    the log format

  • Logging Primitive.

    This method can be used if you have a prepared va_list. Similar to log:level:flag:context:file:function:line:tag:format:...

    Declaration

    Objective-C

    + (void)log:(BOOL)asynchronous
           level:(AWSDDLogLevel)level
            flag:(AWSDDLogFlag)flag
         context:(NSInteger)context
            file:(nonnull const char *)file
        function:(nullable const char *)function
            line:(NSUInteger)line
             tag:(nullable id)tag
          format:(nonnull NSString *)format
            args:(struct __va_list_tag *)argList;

    Swift

    class func log(asynchronous: Bool, level: AWSDDLogLevel, flag: AWSDDLogFlag, context: Int, file: UnsafePointer<CChar>, function: UnsafePointer<CChar>?, line: UInt, tag: Any?, format: String, arguments argList: CVaListPointer)

    Parameters

    asynchronous

    YES if the logging is done async, NO if you want to force sync

    level

    the log level

    flag

    the log flag

    context

    the context (if any is defined)

    file

    the current file

    function

    the current function

    line

    the current code line

    tag

    potential tag

    format

    the log format

    argList

    the arguments list as a va_list

  • Logging Primitive.

    This method can be used if you have a prepared va_list. Similar to log:level:flag:context:file:function:line:tag:format:...

    Declaration

    Objective-C

    - (void)log:(BOOL)asynchronous
           level:(AWSDDLogLevel)level
            flag:(AWSDDLogFlag)flag
         context:(NSInteger)context
            file:(nonnull const char *)file
        function:(nullable const char *)function
            line:(NSUInteger)line
             tag:(nullable id)tag
          format:(nonnull NSString *)format
            args:(struct __va_list_tag *)argList;

    Swift

    func log(asynchronous: Bool, level: AWSDDLogLevel, flag: AWSDDLogFlag, context: Int, file: UnsafePointer<CChar>, function: UnsafePointer<CChar>?, line: UInt, tag: Any?, format: String, arguments argList: CVaListPointer)

    Parameters

    asynchronous

    YES if the logging is done async, NO if you want to force sync

    level

    the log level

    flag

    the log flag

    context

    the context (if any is defined)

    file

    the current file

    function

    the current function

    line

    the current code line

    tag

    potential tag

    format

    the log format

    argList

    the arguments list as a va_list

  • Logging Primitive.

    This method can be used if you manually prepared AWSDDLogMessage.

    Declaration

    Objective-C

    + (void)log:(BOOL)asynchronous message:(nonnull AWSDDLogMessage *)logMessage;

    Swift

    class func log(asynchronous: Bool, message logMessage: AWSDDLogMessage)

    Parameters

    asynchronous

    YES if the logging is done async, NO if you want to force sync

    logMessage

    the log message stored in a AWSDDLogMessage model object

  • Logging Primitive.

    This method can be used if you manually prepared AWSDDLogMessage.

    Declaration

    Objective-C

    - (void)log:(BOOL)asynchronous message:(nonnull AWSDDLogMessage *)logMessage;

    Swift

    func log(asynchronous: Bool, message logMessage: AWSDDLogMessage)

    Parameters

    asynchronous

    YES if the logging is done async, NO if you want to force sync

    logMessage

    the log message stored in a AWSDDLogMessage model object

  • Since logging can be asynchronous, there may be times when you want to flush the logs. The framework invokes this automatically when the application quits.

    Declaration

    Objective-C

    + (void)flushLog;

    Swift

    class func flushLog()
  • Since logging can be asynchronous, there may be times when you want to flush the logs. The framework invokes this automatically when the application quits.

    Declaration

    Objective-C

    - (void)flushLog;

    Swift

    func flushLog()
  • Adds the logger to the system.

    This is equivalent to invoking [AWSDDLog addLogger:logger withLogLevel:AWSDDLogLevelAll].

    Declaration

    Objective-C

    + (void)addLogger:(nonnull id<AWSDDLogger>)logger;

    Swift

    class func add(_ logger: AWSDDLogger)
  • Adds the logger to the system.

    This is equivalent to invoking [AWSDDLog addLogger:logger withLogLevel:AWSDDLogLevelAll].

    Declaration

    Objective-C

    - (void)addLogger:(nonnull id<AWSDDLogger>)logger;

    Swift

    func add(_ logger: AWSDDLogger)
  • Adds the logger to the system.

    The level that you provide here is a preemptive filter (for performance). That is, the level specified here will be used to filter out logMessages so that the logger is never even invoked for the messages.

    More information: When you issue a log statement, the logging framework iterates over each logger, and checks to see if it should forward the logMessage to the logger. This check is done using the level parameter passed to this method.

    For example:

    [AWSDDLog addLogger:consoleLogger withLogLevel:AWSDDLogLevelVerbose]; [AWSDDLog addLogger:fileLogger withLogLevel:AWSDDLogLevelWarning];

    AWSDDLogError(@"oh no"); => gets forwarded to consoleLogger & fileLogger AWSDDLogInfo(@"hi"); => gets forwarded to consoleLogger only

    It is important to remember that Lumberjack uses a BITMASK. Many developers & third party frameworks may define extra log levels & flags. For example:

    #define SOME_FRAMEWORK_LOG_FLAG_TRACE (1 << 6) // 0...1000000

    So if you specify AWSDDLogLevelVerbose to this method, you won’t see the framework’s trace messages.

    (SOME_FRAMEWORK_LOG_FLAG_TRACE & AWSDDLogLevelVerbose) => (01000000 & 00011111) => NO

    Consider passing AWSDDLogLevelAll to this method, which has all bits set. You can also use the exclusive-or bitwise operator to get a bitmask that has all flags set, except the ones you explicitly don’t want. For example, if you wanted everything except verbose & debug:

    ((AWSDDLogLevelAll ^ AWSDDLogLevelVerbose) | AWSDDLogLevelInfo)

    Declaration

    Objective-C

    + (void)addLogger:(nonnull id<AWSDDLogger>)logger
            withLevel:(AWSDDLogLevel)level;

    Swift

    class func add(_ logger: AWSDDLogger, with level: AWSDDLogLevel)
  • Adds the logger to the system.

    The level that you provide here is a preemptive filter (for performance). That is, the level specified here will be used to filter out logMessages so that the logger is never even invoked for the messages.

    More information: When you issue a log statement, the logging framework iterates over each logger, and checks to see if it should forward the logMessage to the logger. This check is done using the level parameter passed to this method.

    For example:

    [AWSDDLog addLogger:consoleLogger withLogLevel:AWSDDLogLevelVerbose]; [AWSDDLog addLogger:fileLogger withLogLevel:AWSDDLogLevelWarning];

    AWSDDLogError(@"oh no"); => gets forwarded to consoleLogger & fileLogger AWSDDLogInfo(@"hi"); => gets forwarded to consoleLogger only

    It is important to remember that Lumberjack uses a BITMASK. Many developers & third party frameworks may define extra log levels & flags. For example:

    #define SOME_FRAMEWORK_LOG_FLAG_TRACE (1 << 6) // 0...1000000

    So if you specify AWSDDLogLevelVerbose to this method, you won’t see the framework’s trace messages.

    (SOME_FRAMEWORK_LOG_FLAG_TRACE & AWSDDLogLevelVerbose) => (01000000 & 00011111) => NO

    Consider passing AWSDDLogLevelAll to this method, which has all bits set. You can also use the exclusive-or bitwise operator to get a bitmask that has all flags set, except the ones you explicitly don’t want. For example, if you wanted everything except verbose & debug:

    ((AWSDDLogLevelAll ^ AWSDDLogLevelVerbose) | AWSDDLogLevelInfo)

    Declaration

    Objective-C

    - (void)addLogger:(nonnull id<AWSDDLogger>)logger
            withLevel:(AWSDDLogLevel)level;

    Swift

    func add(_ logger: AWSDDLogger, with level: AWSDDLogLevel)
  • Remove the logger from the system

    Declaration

    Objective-C

    + (void)removeLogger:(nonnull id<AWSDDLogger>)logger;

    Swift

    class func remove(_ logger: AWSDDLogger)
  • Remove the logger from the system

    Declaration

    Objective-C

    - (void)removeLogger:(nonnull id<AWSDDLogger>)logger;

    Swift

    func remove(_ logger: AWSDDLogger)
  • Remove all the current loggers

    Declaration

    Objective-C

    + (void)removeAllLoggers;

    Swift

    class func removeAllLoggers()
  • Remove all the current loggers

    Declaration

    Objective-C

    - (void)removeAllLoggers;

    Swift

    func removeAllLoggers()
  • Return all the current loggers

    Declaration

    Objective-C

    @property (class, nonatomic, copy, readonly) NSArray<id<AWSDDLogger>> *_Nonnull allLoggers;

    Swift

    class var allLoggers: [AWSDDLogger] { get }
  • Return all the current loggers

    Declaration

    Objective-C

    @property (nonatomic, copy, readonly) NSArray<id<AWSDDLogger>> *_Nonnull allLoggers;

    Swift

    var allLoggers: [AWSDDLogger] { get }
  • Return all the current loggers with their level (aka AWSDDLoggerInformation).

    Declaration

    Objective-C

    @property (class, nonatomic, copy, readonly) NSArray<AWSDDLoggerInformation *> *_Nonnull allLoggersWithLevel;

    Swift

    class var allLoggersWithLevel: [AWSDDLoggerInformation] { get }
  • Return all the current loggers with their level (aka AWSDDLoggerInformation).

    Declaration

    Objective-C

    @property (nonatomic, copy, readonly) NSArray<AWSDDLoggerInformation *> *_Nonnull allLoggersWithLevel;

    Swift

    var allLoggersWithLevel: [AWSDDLoggerInformation] { get }
  • Returns an array with the classes that are using registered dynamic logging

    Declaration

    Objective-C

    @property (class, nonatomic, copy, readonly) NSArray<Class> *_Nonnull registeredClasses;

    Swift

    class var registeredClasses: [AnyClass] { get }
  • Returns an array with the classes names that are using registered dynamic logging

    Declaration

    Objective-C

    @property (class, nonatomic, copy, readonly) NSArray<NSString *> *_Nonnull registeredClassNames;

    Swift

    class var registeredClassNames: [String] { get }
  • Returns the current log level for a certain class

    Declaration

    Objective-C

    + (AWSDDLogLevel)levelForClass:(nonnull Class)aClass;

    Swift

    class func level(for aClass: AnyClass) -> AWSDDLogLevel

    Parameters

    aClass

    Class param

  • Returns the current log level for a certain class

    Declaration

    Objective-C

    + (AWSDDLogLevel)levelForClassWithName:(nonnull NSString *)aClassName;

    Swift

    class func levelForClass(withName aClassName: String) -> AWSDDLogLevel

    Parameters

    aClassName

    string param

  • Set the log level for a certain class

    Declaration

    Objective-C

    + (void)setLevel:(AWSDDLogLevel)level forClass:(nonnull Class)aClass;

    Swift

    class func setLevel(_ level: AWSDDLogLevel, for aClass: AnyClass)

    Parameters

    level

    the new level

    aClass

    Class param

  • Set the log level for a certain class

    Declaration

    Objective-C

    + (void)setLevel:(AWSDDLogLevel)level
        forClassWithName:(nonnull NSString *)aClassName;

    Swift

    class func setLevel(_ level: AWSDDLogLevel, forClassWithName aClassName: String)

    Parameters

    level

    the new level

    aClassName

    string param