@@ -79,7 +79,7 @@ + (void) readAndParseLogFile {
79
79
// Process each log entry
80
80
for (NSString *logEntry in newLogEntries) {
81
81
if ([logEntry length ] > 0 ) {
82
- [NRLogger logMessage : logEntry withTimestamp: [NRAutoLogCollector extractTimestamp: logEntry]];
82
+ [NRLogger log: [NRAutoLogCollector extractType: logEntry] withMessage : logEntry withTimestamp: [NRAutoLogCollector extractTimestamp: logEntry]];
83
83
}
84
84
}
85
85
}
@@ -107,11 +107,39 @@ + (NSNumber *) extractTimestamp:(NSString *) inputString {
107
107
if ([NRAutoLogCollector isValidTimestamp: (timestampString)]) {
108
108
NSNumberFormatter *formatter = [[NSNumberFormatter alloc ] init ];
109
109
formatter.numberStyle = NSNumberFormatterDecimalStyle;
110
- return [formatter numberFromString: timestampString];
110
+ NSNumber * originalTimestamp = [formatter numberFromString: timestampString];
111
+ double timestampInSeconds = [originalTimestamp doubleValue ];
112
+ long long timestampInMilliseconds = (long long )(timestampInSeconds * 1000 );
113
+ return [NSNumber numberWithLongLong: timestampInMilliseconds];
111
114
}
112
115
}
113
116
114
117
return nil ;
115
118
}
116
119
120
+ + (unsigned int ) extractType : (NSString *) inputString {
121
+ // Define the regular expression pattern to match the type: value
122
+ NSString *pattern = @" type:\" ([^\" ]+)\" " ;
123
+ NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern: pattern options: 0 error: nil ];
124
+
125
+ // Find matches in the input string
126
+ NSTextCheckingResult *match = [regex firstMatchInString: inputString options: 0 range: NSMakeRange (0 , [inputString length ])];
127
+
128
+ if (match) {
129
+ // Extract the matched type value
130
+ NSRange typeRange = [match rangeAtIndex: 1 ];
131
+ NSString *typeString = [inputString substringWithRange: typeRange];
132
+ if ([typeString compare: @" Info" ] == NSOrderedSame || [typeString compare: @" Default" ] == NSOrderedSame){
133
+ return NRLogLevelInfo;
134
+ } else if ([typeString compare: @" Debug" ] == NSOrderedSame){
135
+ return NRLogLevelDebug;
136
+ } else if ([typeString compare: @" Error" ] == NSOrderedSame || [typeString compare: @" Fault" ] == NSOrderedSame){
137
+ return NRLogLevelError;
138
+ }
139
+ }
140
+
141
+ return NRLogLevelNone;
142
+ }
143
+
144
+
117
145
@end
0 commit comments