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;
+2 -2
View File
@@ -16,7 +16,7 @@
<window title="Debug Log" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="SBDebugLogWindow" animationBehavior="default" id="F0z-JX-Cv5">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="1612" y="940" width="470" height="500"/>
<rect key="contentRect" x="147" y="812" width="470" height="500"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
<view key="contentView" id="se5-gp-TjO">
<rect key="frame" x="0.0" y="0.0" width="470" height="500"/>
@@ -30,7 +30,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView editable="NO" importsGraphics="NO" findStyle="panel" allowsUndo="YES" verticallyResizable="YES" allowsNonContiguousLayout="YES" id="Ztd-g7-f0E">
<rect key="frame" x="0.0" y="0.0" width="223" height="276"/>
<rect key="frame" x="0.0" y="0.0" width="223" height="466"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<size key="minSize" width="470" height="466"/>