I am attempting to find a logging framework for a Cocoa application, written in ObjC.
What I\'ve attempted so far:
You can use the Foundation function NSSetUncaughtExceptionHandler to set a callback function that will handle all uncaught exceptions:
void CustomLogger(NSString *format, ...) {
//do other awesome logging stuff here...
}
void uncaughtExceptionHandler(NSException *exception) {
//do something useful, like this:
CustomLogger(@"%@", [exception reason]);
}
NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler);
For NSLog
, you can use a macro to override it :)
#define NSLog(...) CustomLogger(__VA_ARGS__);