Skip to content

Instantly share code, notes, and snippets.

@jgimenez
Last active October 19, 2016 10:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgimenez/8b8dce1b6e97b237eed815a05d31271c to your computer and use it in GitHub Desktop.
Save jgimenez/8b8dce1b6e97b237eed815a05d31271c to your computer and use it in GitHub Desktop.
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