Permalink
Browse files

Allow unicode characters in log files, and add some logging to report…

… the incremental progress of the parser
  • Loading branch information...
1 parent 4bdcdd0 commit 26efe640c18166c5c85e6fe13e9b08c3615b9773 @wronco wronco committed Mar 21, 2011
Showing with 14 additions and 5 deletions.
  1. +7 −1 LogParser.m
  2. +7 −4 ParamParser.m
View
@@ -66,7 +66,8 @@ - (void)parseLogData:(NSData *)data {
data = [data subdataWithRange:NSMakeRange( highWaterMark, [data length] - highWaterMark )];
[progressController setStatus:@"Scanning log data"];
- NSString *content = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
+ //NSString *content = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
+ NSString *content = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSArray *lines = [content componentsSeparatedByString:@"\n"];
[progressController setStatus:@"Parsing log data"];
@@ -92,6 +93,7 @@ - (NSArray *)parseLogLines:(NSArray *)lines {
NSMutableArray *lineGroup = [[NSMutableArray alloc] init];
+ NSDate *start = [NSDate date];
for( NSString *line in lines ) {
line = [line stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
line = [line stringByRemovingANSIEscapeSequences];
@@ -113,6 +115,10 @@ - (NSArray *)parseLogLines:(NSArray *)lines {
}
linesProcessed += 1;
+ if ((int)linesProcessed % 10000 == 0){
+ NSLog(@"%f processed in %f seconds", linesProcessed, [start timeIntervalSinceNow]);
+
+ }
[progressController update:linesProcessed];
}
View
@@ -43,10 +43,13 @@ + (void)initialize {
- (id)init {
if( ( self = [super init] ) ) {
- NSString *rubyHashGrammar = [NSString stringWithContentsOfFile:[self grammarPath]
- encoding:NSUTF8StringEncoding
- error:nil];
- parser = [[TDParserFactory factory] parserFromGrammar:rubyHashGrammar
+ NSString *rubyHashGrammar = [NSString stringWithContentsOfFile:[self grammarPath]
+ encoding:NSUTF8StringEncoding
+ error:nil];
+// NSString *rubyHashGrammar = [NSString stringWithContentsOfFile:[self grammarPath]
+// encoding:NSUnicodeStringEncoding
+// error:nil];
+ parser = [[TDParserFactory factory] parserFromGrammar:rubyHashGrammar
assembler:self
getTokenizer:&tokenizer];

0 comments on commit 26efe64

Please sign in to comment.