mirror of
https://github.com/transmission/transmission
synced 2025-03-09 21:54:09 +00:00
get writing message log to a file working again
This commit is contained in:
parent
2e74340491
commit
f09ece6d88
1 changed files with 14 additions and 13 deletions
|
@ -105,11 +105,7 @@
|
||||||
if ((messages = tr_getQueuedMessages()) == NULL)
|
if ((messages = tr_getQueuedMessages()) == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//keep scrolled to bottom if already at bottom or there is no scroll bar yet
|
NSString * levelString;
|
||||||
NSScroller * scroller = [fScrollView verticalScroller];
|
|
||||||
BOOL shouldScroll = [scroller floatValue] == 1.0 || [scroller isHidden] || [scroller knobProportion] == 1.0;
|
|
||||||
|
|
||||||
NSString * levelString, * dateString, * messageString;
|
|
||||||
for (currentMessage = messages; currentMessage != NULL; currentMessage = currentMessage->next)
|
for (currentMessage = messages; currentMessage != NULL; currentMessage = currentMessage->next)
|
||||||
{
|
{
|
||||||
int level = currentMessage->level;
|
int level = currentMessage->level;
|
||||||
|
@ -144,9 +140,6 @@
|
||||||
[fMessageView reloadData];
|
[fMessageView reloadData];
|
||||||
|
|
||||||
tr_freeMessageList(messages);
|
tr_freeMessageList(messages);
|
||||||
|
|
||||||
/*if (shouldScroll)
|
|
||||||
[fTextView scrollRangeToVisible: NSMakeRange([[fTextView string] length], 0)];*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (int) numberOfRowsInTableView: (NSTableView *) tableView
|
- (int) numberOfRowsInTableView: (NSTableView *) tableView
|
||||||
|
@ -199,7 +192,15 @@
|
||||||
|
|
||||||
- (void) writeToFile: (id) sender
|
- (void) writeToFile: (id) sender
|
||||||
{
|
{
|
||||||
/*NSString * string = [[fTextView string] retain];
|
//create the text to output
|
||||||
|
NSMutableArray * messageStrings = [NSMutableArray arrayWithCapacity: [fMessages count]];
|
||||||
|
|
||||||
|
NSEnumerator * enumerator = [fMessages objectEnumerator];
|
||||||
|
NSDictionary * message;
|
||||||
|
while ((message = [enumerator nextObject]))
|
||||||
|
[messageStrings addObject: [self stringForMessage: message]];
|
||||||
|
|
||||||
|
NSString * fileString = [[messageStrings componentsJoinedByString: @"\n"] retain];
|
||||||
|
|
||||||
NSSavePanel * panel = [NSSavePanel savePanel];
|
NSSavePanel * panel = [NSSavePanel savePanel];
|
||||||
[panel setRequiredFileType: @"txt"];
|
[panel setRequiredFileType: @"txt"];
|
||||||
|
@ -207,12 +208,12 @@
|
||||||
|
|
||||||
[panel beginSheetForDirectory: nil file: NSLocalizedString(@"untitled", "Save log panel -> default file name")
|
[panel beginSheetForDirectory: nil file: NSLocalizedString(@"untitled", "Save log panel -> default file name")
|
||||||
modalForWindow: [self window] modalDelegate: self
|
modalForWindow: [self window] modalDelegate: self
|
||||||
didEndSelector: @selector(writeToFileSheetClosed:returnCode:contextInfo:) contextInfo: string];*/
|
didEndSelector: @selector(writeToFileSheetClosed:returnCode:contextInfo:) contextInfo: fileString];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) writeToFileSheetClosed: (NSSavePanel *) panel returnCode: (int) code contextInfo: (NSString *) string
|
- (void) writeToFileSheetClosed: (NSSavePanel *) panel returnCode: (int) code contextInfo: (NSString *) string
|
||||||
{
|
{
|
||||||
/*if (code == NSOKButton)
|
if (code == NSOKButton)
|
||||||
{
|
{
|
||||||
if (![string writeToFile: [panel filename] atomically: YES encoding: NSUTF8StringEncoding error: nil])
|
if (![string writeToFile: [panel filename] atomically: YES encoding: NSUTF8StringEncoding error: nil])
|
||||||
{
|
{
|
||||||
|
@ -230,7 +231,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[string release];*/
|
[string release];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -239,7 +240,7 @@
|
||||||
|
|
||||||
- (NSString *) stringForMessage: (NSDictionary *) message
|
- (NSString *) stringForMessage: (NSDictionary *) message
|
||||||
{
|
{
|
||||||
return [NSString stringWithFormat: @"%@\n%@\n\n%@", [message objectForKey: @"Date"],
|
return [NSString stringWithFormat: @"%@ %@ %@", [message objectForKey: @"Date"],
|
||||||
[message objectForKey: @"Level"], [message objectForKey: @"Message"]];
|
[message objectForKey: @"Level"], [message objectForKey: @"Message"]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue