Changeset 5263


Ignore:
Timestamp:
Mar 16, 2008, 3:26:53 PM (14 years ago)
Author:
livings124
Message:

cleanup of the message window code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/MessageWindowController.m

    r5257 r5263  
    151151    for (currentMessage = messages; currentMessage != NULL; currentMessage = currentMessage->next)
    152152    {
    153         NSMutableDictionary * message  = [NSMutableDictionary dictionaryWithObjectsAndKeys:
    154                                         [NSString stringWithUTF8String: currentMessage->message], @"Message",
    155                                         [NSDate dateWithTimeIntervalSince1970: currentMessage->when], @"Date",
    156                                         [NSNumber numberWithInt: currentMessage->level], @"Level", nil];
     153        NSString * name = currentMessage->name != NULL ? [NSString stringWithUTF8String: currentMessage->name]
     154                            : [[NSProcessInfo processInfo] processName];
    157155       
    158         if (currentMessage->file != NULL)
    159         {
    160             [message setObject: [NSString stringWithUTF8String: currentMessage->file] forKey: @"File"];
    161             [message setObject: [NSNumber numberWithInt: currentMessage->line] forKey: @"Line"];
    162         }
    163        
    164         if (currentMessage->name != NULL)
    165             [message setObject: [NSString stringWithUTF8String: currentMessage->name] forKey: @"Name"];
     156        NSDictionary * message  = [NSDictionary dictionaryWithObjectsAndKeys:
     157                                    [NSString stringWithUTF8String: currentMessage->message], @"Message",
     158                                    [NSDate dateWithTimeIntervalSince1970: currentMessage->when], @"Date",
     159                                    [NSNumber numberWithInt: currentMessage->level], @"Level",
     160                                    name, @"Name",
     161                                    [NSString stringWithUTF8String: currentMessage->file], @"File",
     162                                    [NSNumber numberWithInt: currentMessage->line], @"Line", nil];
    166163                               
    167164        [fMessages addObject: message];
     
    380377    }
    381378   
    382     NSMutableArray * strings = [NSMutableArray arrayWithObjects: [message objectForKey: @"Date"],
    383                                 [NSString stringWithFormat: @"[%@]", level], [message objectForKey: @"Message"], nil];
    384    
    385     NSString * name;
    386     if ((name = [message objectForKey: @"Name"]))
    387         [strings insertObject: [name stringByAppendingString: @":"] atIndex: 2];
    388    
    389     NSString * file;
    390     if ((file = [self fileForMessage: message]))
    391         [strings insertObject: file atIndex: 1];
    392    
    393     return [strings componentsJoinedByString: @" "];
     379    return [NSString stringWithFormat: @"%@ %@ %@: [%@] %@", [message objectForKey: @"Date"], [self fileForMessage: message],
     380            [message objectForKey: @"Name"], level, [message objectForKey: @"Message"], nil];
    394381}
    395382
Note: See TracChangeset for help on using the changeset viewer.