-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RollbarCocoaLumberjackLogger: prototype is code complete
- Loading branch information
Showing
10 changed files
with
242 additions
and
35 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
58 changes: 57 additions & 1 deletion
58
RollbarCocoaLumberjack/Tests/RollbarCocoaLumberjackTests-ObjC/RollbarCocoaLumberjackTests.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
16 changes: 16 additions & 0 deletions
16
RollbarCocoaLumberjack/Tests/RollbarCocoaLumberjackTests-ObjC/RollbarTestUtil.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,16 @@ | ||
// Copyright (c) 2018 Rollbar, Inc. All rights reserved. | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@import RollbarNotifier; | ||
|
||
void RollbarClearLogFile(void); | ||
NSArray* RollbarReadLogItemFromFile(void); | ||
void RollbarFlushFileThread(RollbarLogger *logger); | ||
|
||
@interface RollbarLogger (Tests) | ||
|
||
- (NSThread *)_rollbarThread; | ||
- (void)_test_doNothing; | ||
|
||
@end |
66 changes: 66 additions & 0 deletions
66
RollbarCocoaLumberjack/Tests/RollbarCocoaLumberjackTests-ObjC/RollbarTestUtil.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,66 @@ | ||
// Copyright (c) 2018 Rollbar, Inc. All rights reserved. | ||
|
||
#import "RollbarTestUtil.h" | ||
#import "RollbarFileReader.h" | ||
#import "RollbarCachesDirectory.h" | ||
|
||
static NSString *QUEUED_ITEMS_FILE_NAME = @"rollbar.items"; | ||
static NSString *QUEUED_ITEMS_STATE_FILE_NAME = @"rollbar.state"; | ||
static NSString *QUEUED_TELEMETRY_ITEMS_FILE_NAME = @"rollbar.telemetry"; | ||
|
||
NSString* _logFilePath() { | ||
|
||
NSString *cachesDirectory = [RollbarCachesDirectory directory]; | ||
return [cachesDirectory stringByAppendingPathComponent:QUEUED_ITEMS_FILE_NAME]; | ||
} | ||
|
||
void RollbarClearLogFile() { | ||
|
||
NSString *filePath = _logFilePath(); | ||
NSFileManager *fileManager = [NSFileManager defaultManager]; | ||
NSError *error; | ||
BOOL fileExists = [fileManager fileExistsAtPath:filePath]; | ||
|
||
if (fileExists) { | ||
BOOL success = [fileManager removeItemAtPath:filePath | ||
error:&error]; | ||
if (!success) { | ||
NSLog(@"Error: %@", [error localizedDescription]); | ||
} | ||
[[NSFileManager defaultManager] createFileAtPath:filePath | ||
contents:nil | ||
attributes:nil]; | ||
} | ||
} | ||
|
||
NSArray* RollbarReadLogItemFromFile() { | ||
|
||
NSString *filePath = _logFilePath(); | ||
RollbarFileReader *reader = [[RollbarFileReader alloc] initWithFilePath:filePath | ||
andOffset:0]; | ||
|
||
NSMutableArray *items = [NSMutableArray array]; | ||
[reader enumerateLinesUsingBlock:^(NSString *line, NSUInteger nextOffset, BOOL *stop) { | ||
NSMutableDictionary *payload = | ||
[NSJSONSerialization JSONObjectWithData:[line dataUsingEncoding:NSUTF8StringEncoding] | ||
options:(NSJSONReadingMutableContainers | NSJSONReadingMutableLeaves) | ||
error:nil | ||
]; | ||
|
||
|
||
if (!payload) { | ||
return; | ||
} | ||
|
||
NSMutableDictionary *data = payload[@"data"]; | ||
[items addObject:data]; | ||
}]; | ||
|
||
return items; | ||
} | ||
|
||
void RollbarFlushFileThread(RollbarLogger *logger) { | ||
|
||
[logger performSelector:@selector(_test_doNothing) | ||
onThread:[logger _rollbarThread] withObject:nil waitUntilDone:YES]; | ||
} |
9 changes: 0 additions & 9 deletions
9
RollbarCommon/Tests/RollbarCommonTests-ObjC/RollbarCommonTests.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
7 changes: 0 additions & 7 deletions
7
RollbarCommon/Tests/RollbarCommonTests-ObjC/RollbarCrashReportUtilTest.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
7 changes: 0 additions & 7 deletions
7
RollbarCommon/Tests/RollbarCommonTests-ObjC/RollbarHostingProcessUtilTest.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
7 changes: 0 additions & 7 deletions
7
RollbarCommon/Tests/RollbarCommonTests-ObjC/RollbarPredicateBuilderTests.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
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