Commits

Kunal Parmar committed 985be72

Format the time first and message last in the basic formatter.

Comments (0)

Files changed (1)

Sources/KPTASLReader.m

   NSDictionary *properties = [message properties];
   NSMutableArray *formattedValues =
     [NSMutableArray arrayWithCapacity:[properties count]];
+  __block NSString *formattedMessage = nil;
+
   [properties enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
     (void)stop;
     NSString *formattedValue = [self stringForMessageProperty:key
                                                         value:obj];
     if ([formattedValue length] > 0)
     {
-      [formattedValues addObject:formattedValue];
+      // Time should be first.
+      if ([key isEqualToString:kKPTASLMessagePropertyTime])
+      {
+        [formattedValues insertObject:formattedValue
+                              atIndex:0];
+      }
+      // Message will be inserted at the end.
+      else if ([key isEqualToString:kKPTASLMessagePropertyMessage])
+      {
+        formattedMessage = formattedValue;
+      }
+      else
+      {
+        [formattedValues addObject:formattedValue];
+      }
     }
   }];
+
+  if (formattedMessage)
+  {
+    [formattedValues addObject:formattedMessage];
+  }
+
   return [formattedValues componentsJoinedByString:@" "];
 }