Created
March 28, 2013 13:34
-
-
Save mikekatz/5263150 to your computer and use it in GitHub Desktop.
Configurable log redirect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//the log manager's log method. Each log channel formats its message and then sends the whole string to this method | |
- (void) log:(NSString*)message | |
{ | |
if (self.logSink == nil) { | |
NSLog(@"%@", message); | |
} else { | |
[self.logSink log:message]; | |
} | |
} | |
//if a sink is installed and implements this protocol, it will be called instead. | |
//This sink can then redirect the message to disk, a web service, console, etc. | |
//This sink is installed when the library is configured during app launch | |
@protocol KCSLogSink <NSObject> | |
/** Take the incoming `message` and send it somewhere; e.g. STDOUT, NSLog, or a custom logger. | |
@see +[KinveyKit configureLoggingWithNetworkEnabled:debugEnabled:traceEnabled:warningEnabled:errorEnabled:] | |
@param message the KinveyKit log message | |
@since 1.14.0 | |
*/ | |
- (void) log:(NSString*)message; | |
@end | |
// example implementation | |
@interface TestFlightLogger : NSObject <KCSLogSink> | |
@end | |
@implementation TestFlightLogger | |
- (void)log:(NSString *)message | |
{ | |
TFLog(@"%@", message); | |
} | |
@end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment