1. Kunal Parmar
  2. kp-toolkit

Commits

Kunal Parmar  committed 985be72

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

  • Participants
  • Parent commits c649f5d
  • Branches master

Comments (0)

Files changed (1)

File Sources/KPTASLReader.m

View file
  • Ignore whitespace
   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:@" "];
 }