forked from kstenerud/KSCrash
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also moved framework/module stuff to a common area.
- Loading branch information
Showing
8 changed files
with
258 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
File renamed without changes.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// KSCrashInstallationConsole.h | ||
// KSCrash-iOS | ||
// | ||
// Copyright (c) 2012 Karl Stenerud. All rights reserved. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall remain in place | ||
// in this source code. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
// | ||
|
||
#import "KSCrashInstallation.h" | ||
|
||
/** Prints all reports to the console. | ||
* This class is intended for testing purposes. | ||
*/ | ||
@interface KSCrashInstallationConsole : KSCrashInstallation | ||
|
||
@property(nonatomic,readwrite) BOOL printAppleFormat; | ||
|
||
+ (instancetype) sharedInstance; | ||
|
||
@end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// | ||
// KSCrashInstallationConsole.m | ||
// KSCrash-iOS | ||
// | ||
// Copyright (c) 2012 Karl Stenerud. All rights reserved. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall remain in place | ||
// in this source code. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
// | ||
|
||
#import "KSCrashInstallationConsole.h" | ||
#import "KSCrashInstallation+Private.h" | ||
#import "KSCrashReportSinkConsole.h" | ||
#import "KSCrashReportFilterAppleFmt.h" | ||
#import "KSCrashReportFilterJSON.h" | ||
#import "KSCrashReportFilterStringify.h" | ||
#import "KSSingleton.h" | ||
|
||
@implementation KSCrashInstallationConsole | ||
|
||
IMPLEMENT_EXCLUSIVE_SHARED_INSTANCE(KSCrashInstallationConsole) | ||
|
||
@synthesize printAppleFormat = _printAppleFormat; | ||
|
||
- (id) init | ||
{ | ||
if((self = [super initWithRequiredProperties:nil])) | ||
{ | ||
self.printAppleFormat = NO; | ||
} | ||
return self; | ||
} | ||
|
||
- (id<KSCrashReportFilter>) sink | ||
{ | ||
id<KSCrashReportFilter> formatFilter; | ||
if(self.printAppleFormat) | ||
{ | ||
formatFilter = [KSCrashReportFilterAppleFmt filterWithReportStyle:KSAppleReportStyleSymbolicated]; | ||
} | ||
else | ||
{ | ||
formatFilter = [KSCrashReportFilterPipeline filterWithFilters: | ||
[KSCrashReportFilterJSONEncode filterWithOptions:KSJSONEncodeOptionPretty | KSJSONEncodeOptionSorted], | ||
[KSCrashReportFilterStringify new], | ||
nil]; | ||
} | ||
|
||
return [KSCrashReportFilterPipeline filterWithFilters: | ||
formatFilter, | ||
[KSCrashReportSinkConsole new], | ||
nil]; | ||
} | ||
|
||
@end |
34 changes: 34 additions & 0 deletions
34
Source/KSCrash/Reporting/Filters/KSCrashReportFilterStringify.h
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// KSCrashReportFilterStringify.h | ||
// KSCrash | ||
// | ||
// Copyright (c) 2012 Karl Stenerud. All rights reserved. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall remain in place | ||
// in this source code. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
// | ||
|
||
#import "KSCrashReportFilter.h" | ||
|
||
/** Converts objects into strings. | ||
*/ | ||
@interface KSCrashReportFilterStringify : NSObject <KSCrashReportFilter> | ||
|
||
+ (KSCrashReportFilterStringify*) filter; | ||
|
||
@end |
61 changes: 61 additions & 0 deletions
61
Source/KSCrash/Reporting/Filters/KSCrashReportFilterStringify.m
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// | ||
// KSCrashReportFilterStringify.m | ||
// KSCrash | ||
// | ||
// Copyright (c) 2012 Karl Stenerud. All rights reserved. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall remain in place | ||
// in this source code. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
// | ||
|
||
#import "KSCrashReportFilterStringify.h" | ||
#import "KSCrashCallCompletion.h" | ||
|
||
@implementation KSCrashReportFilterStringify | ||
|
||
+ (KSCrashReportFilterStringify*) filter | ||
{ | ||
return [[self alloc] init]; | ||
} | ||
|
||
- (NSString*) stringifyObject:(id) object | ||
{ | ||
if([object isKindOfClass:[NSString class]]) | ||
{ | ||
return object; | ||
} | ||
if([object isKindOfClass:[NSData class]]) | ||
{ | ||
return [[NSString alloc] initWithData:object encoding:NSUTF8StringEncoding]; | ||
} | ||
return [NSString stringWithFormat:@"%@", object]; | ||
} | ||
|
||
- (void) filterReports:(NSArray*) reports | ||
onCompletion:(KSCrashReportFilterCompletion) onCompletion | ||
{ | ||
NSMutableArray* filteredReports = [NSMutableArray arrayWithCapacity:[reports count]]; | ||
for(id report in reports) | ||
{ | ||
[filteredReports addObject:[self stringifyObject:report]]; | ||
} | ||
|
||
kscrash_i_callCompletion(onCompletion, filteredReports, YES, nil); | ||
} | ||
|
||
@end |
Oops, something went wrong.