Thanks, and with the help of http://doing-it-wrong.mikeweller.com/2012/07/youre-doing-it-wrong-1-nslogdebug-ios.html I made the following changes:
The BRASL.h file has been added to the project with the following contents:
// // BRASL.h // #ifndef BRASL_h #define BRASL_h #import <asl.h> #import <Foundation/Foundation.h> // Define which loglevel is necessary for deployment and development // ================================================================= // Used to conditionally implement the log functions. All log // functions are defined so the compiler does not complain. But only // those logfunctions that are used will contain code. // ================================================================= #ifndef BRASL_LOG_LEVEL // DEBUG is set in the project build-settings #if DEBUG == 1 // Set logging level for development #define BRASL_LOG_LEVEL ASL_LEVEL_DEBUG #else // Set logging level for deployment #define BRASL_LOG_LEVEL ASL_LEVEL_NOTICE #endif #endif // Define the log functions // ======================== void aslEmergency(NSString *string); void aslAlert(NSString *string); void aslCritical(NSString *string); void aslError(NSString *string); void aslWarning(NSString *string); void aslNotice(NSString *string); void aslInfo(NSString *string); void aslDebug(NSString *string); #endif
Then the corresponding .m file is added with:
// // BRASL.h // #import "BRASL.h" // We need this to set asl up to also write the information to the debugger // ======================================================================== static void AddStderrOnce() { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ asl_add_log_file(NULL, STDERR_FILENO); }); } // Implement the log functions where necessary // =========================================== #if BRASL_LOG_LEVEL >= ASL_LEVEL_EMERG void aslEmergency(NSString *string) { AddStderrOnce(); asl_log(NULL, NULL, ASL_LEVEL_EMERG, "%s", [string UTF8String]); } #else void aslEmergency(NSString *string) {} #endif #if BRASL_LOG_LEVEL >= ASL_LEVEL_ALERT void aslAlert(NSString *string) { AddStderrOnce(); asl_log(NULL, NULL, ASL_LEVEL_ALERT, "%s", [string UTF8String]); } #else void aslAlert(NSString *string) {} #endif #if BRASL_LOG_LEVEL >= ASL_LEVEL_CRIT void aslCritical(NSString *string) { AddStderrOnce(); asl_log(NULL, NULL, ASL_LEVEL_CRIT, "%s", [string UTF8String]); } #else void aslCritical(NSString *string) {} #endif #if BRASL_LOG_LEVEL >= ASL_LEVEL_ERR void aslError(NSString *string) { AddStderrOnce(); asl_log(NULL, NULL, ASL_LEVEL_ERR, "%s", [string UTF8String]); } #else void aslError(NSString *string) {} #endif #if BRASL_LOG_LEVEL >= ASL_LEVEL_WARNING void aslWarning(NSString *string) { AddStderrOnce(); asl_log(NULL, NULL, ASL_LEVEL_WARNING, "%s", [string UTF8String]); } #else void aslWarning(NSString *string) {} #endif #if BRASL_LOG_LEVEL >= ASL_LEVEL_NOTICE void aslNotice(NSString *string) { AddStderrOnce(); asl_log(NULL, NULL, ASL_LEVEL_NOTICE, "%s", [string UTF8String]); } #else void aslNotice(NSString *string) {} #endif #if BRASL_LOG_LEVEL >= ASL_LEVEL_INFO void aslInfo(NSString *string) { AddStderrOnce(); asl_log(NULL, NULL, ASL_LEVEL_INFO, "%s", [string UTF8String]); } #else void aslInfo(NSString *string) {} #endif #if BRASL_LOG_LEVEL >= ASL_LEVEL_DEBUG void aslDebug(NSString *string) { AddStderrOnce(); asl_log(NULL, NULL, ASL_LEVEL_DEBUG, "%s", [string UTF8String]); } #else void aslDebug(NSString *string) {} #endif
And of course the bridge file
// // Use this file to import your target public headers that you would like to expose to Swift. //
Then in my quick code I can use for example:
aslInfo("Initializing managed object context")
So far so good, it seems to work as advertised :)