SDMLogger

The SDMLogger is a programming interface that provides event logging facilities. Its APIs allow generating, retrieving and displaying log items for a specific application.

List of Features

Logger Macros

The SDMLOG macros wrap the logger APIs and automatically enhance the log entry with information such as FILE, FUNCTION and LINE#. The following macros are available (matching the exposed APIs):
SDMLOGEMERGENCY(msg)
SDMLOGALERT(msg)
SDMLOGCRITICAL(msg)
SDMLOGERROR(msg)
SDMLOGWARNING(msg)
SDMLOGNOTICE(msg)
SDMLOGINFO(msg)
SDMLOGDEBUG(msg)

SDMLogger Public APIs

+ (void) enableLogging
+ (void) disableLogging
-(void) displayLogsWithLevel:(LoggingLevels)level_in
-(void) displayLogsWithLevel:(LoggingLevels)level_in forQueryOperation:(QueryOperations)queryOperation;
-(NSArray*) retrieveLogsWithLevel:(LoggingLevels)level_in;
-(NSArray*) retrieveLogsWithLevel:(LoggingLevels)level_in forQueryOperation:(QueryOperations)queryOperation;
-(void) logMessage:(NSString*) message_in withLevel:(LoggingLevels)level_in andInfo:(NSString*) info_in
-(void) logEmergency:(NSString*) message_in withInfo:(NSString*) info_in
-(void) logAlert:(NSString*) message_in withInfo:(NSString*) info_in
-(void) logCritical:(NSString*) message_in withInfo:(NSString*) info_in
-(void) logError:(NSString*) message_in withInfo:(NSString*) info_in
-(void) logWarning:(NSString*) message_in withInfo:(NSString*) info_in
-(void) logNotice:(NSString*) message_in withInfo:(NSString*) info_in
-(void) logInfo:(NSString*) message_in withInfo:(NSString*) info_in
-(void) logDebug:(NSString*) message_in withInfo:(NSString*) info_in

Technical Details

You can enable/disable logging, and display, retrieve and generate logs.

Higher priority log messages are mapped to lower values Mac OS X / iOS system wide (see asl.h). Therefore, use Less or LessEqual query operation to display more critical logs. For example, in order to retrieve all log messages including the lowest, Debug level ones, use the following approach:
[[SDMLogger instance] displayLogsWithLevel:DebugLoggingLevel forQueryOperation:LessEqual];

When generating logs, consider using the SDMLOGxxx macros, because they automatically enhance the log entry with information such as FILE, FUNCTION and LINE#.

The common methods are defined by the SDMLogging protocol. (See also: SDMLogger default implementation.)

The built-in crash log support provided by Apple can be used additionally for supportability purposes. You can retrieve crash logs either by using iTunes or by using the iPhone Configuration Utility. Note that Apple imposes restrictions on an application transmitting any data about the user without the user's prior permission, as described in the App Store review guidelines at http://developer.apple.com/appstore/resources/approval/guidelines.html, see Chapter 17, Privacy.