Skip to content

Instantly share code, notes, and snippets.

@jgimenez jgimenez/README.md
Last active Oct 19, 2016

Embed
What would you like to do?
Twitter Logging Service for iOS output stream to Bugfender

This code lets you use Bugfender as an output stream in your Twitter Logging Service instance.

First of all, set up Twitter Logging Service and Bugfender following the instructions given in their websites.

Then add Bugfender to TLS like this:

TLSLoggingService *logger = [TLSLoggingService sharedInstance];
[logger addOutputStream:[TLSBugfenderOutputStream new]];
//
// TLSBugfenderOutputStream.h
// Copyright © 2016 Bugfender. All rights reserved.
//
#import <Foundation/Foundation.h>
@import TwitterLoggingService;
/**
concrete implementation of a `TLSOutputStream` that uses `NSLog`.
@note Only use one of `TLSStdErrOutputStream`, `TLSNSLogOutputStream` or `TLSOSLogOutputStream`.
*/
@interface TLSBugfenderOutputStream : NSObject <TLSOutputStream>
/** writes the *logInfo* to `NSLog` */
- (void)tls_outputLogInfo:(nonnull TLSLogMessageInfo *)logInfo;
@end
//
// TLSBugfenderOutputStream.h
// Copyright © 2016 Bugfender. All rights reserved.
//
#import "TLSBugfenderOutputStream.h"
#import <BugfenderSDK/BugfenderSDK.h>
@import TwitterLoggingService;
@implementation TLSBugfenderOutputStream
- (void)tls_outputLogInfo:(nonnull TLSLogMessageInfo *)logInfo
{
BFLogLevel bfLogLevel;
switch (logInfo.level) {
case TLSLogLevelEmergency:
case TLSLogLevelAlert:
case TLSLogLevelCritical:
case TLSLogLevelError:
bfLogLevel = BFLogLevelError;
break;
case TLSLogLevelWarning:
bfLogLevel = BFLogLevelWarning;
break;
default:
bfLogLevel = BFLogLevelDefault;
}
[Bugfender logLineNumber:logInfo.line
method:logInfo.function
file:logInfo.file
level:bfLogLevel
tag:logInfo.channel
message:logInfo.message];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.