Save the log to file too.

This commit is contained in:
Damiano Galassi committed 2014-10-24 18:17:15 +02:00
1 parent dc2bd1678f
commit 75da7489fd
5 files changed
+32 -9

No files matched your search

+5 -1
View File
@@ -25,7 +25,11 @@
[SBPrefsController registerUserDefaults];
debugLogController = [[SBDebugLogController alloc] init];
NSString *path = [[NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory,
NSUserDomainMask,
YES) firstObject] stringByAppendingPathComponent:@"Subler/debugLog.txt"];
debugLogController = [[SBDebugLogController alloc] initWithLogFile:[NSURL fileURLWithPath:path]];
[MP42File redirectLogUsingBlock:^(NSString *text) {
[debugLogController log:text];
+3 -1
View File
@@ -9,9 +9,11 @@
#import <Cocoa/Cocoa.h>
@interface SBDebugLogController : NSWindowController {
NSTextView *logView;
NSTextView *_logView;
NSURL *_fileURL;
}
- (instancetype)initWithLogFile:(NSURL *)fileURL;
- (void)log:(NSString *)string;
@end
+19 -5
View File
@@ -11,14 +11,16 @@
@interface SBDebugLogController ()
@property (assign) IBOutlet NSTextView *logView;
@property (readonly) NSURL *fileURL;
@end
@implementation SBDebugLogController
@synthesize logView;
- (instancetype)init
{
@synthesize logView = _logView;
@synthesize fileURL = _fileURL;
- (instancetype)init {
if ((self = [super initWithWindowNibName:@"SBDebugLogWindow"])) {
[self window];
}
@@ -26,12 +28,24 @@
return self;
}
- (instancetype)initWithLogFile:(NSURL *)fileURL {
self = [self init];
- (void)windowDidLoad {
[super windowDidLoad];
if (self) {
_fileURL = [fileURL copy];
[[NSFileManager defaultManager] removeItemAtURL:_fileURL error:nil];
}
return self;
}
- (void)log:(NSString *)string {
if (self.fileURL) {
FILE *f = fopen([self.fileURL fileSystemRepresentation], "a");
fprintf(f, "%s", [string UTF8String]);
fclose(f);
}
dispatch_async(dispatch_get_main_queue(), ^{
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:string];
[[self.logView textStorage] appendAttributedString:attributedString];
+3
View File
@@ -943,6 +943,9 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
[propertyView release];
propertyView = nil;
[fileTracksTable setDelegate:nil];
[fileTracksTable setDataSource:nil];
[languages release];
languages = nil;