Add some additional log messages to track down a tvdb issue.

This commit is contained in:
Damiano Galassi committed 2017-05-31 09:38:46 +02:00
1 parent 7721818507
commit 3d285f692f
5 files changed
+51 -14

No files matched your search

+21 -11
View File
@@ -12,6 +12,7 @@
@interface SBLogger ()
@property (nonatomic, readonly) NSURL *fileURL;
@property (nonatomic, readonly) dispatch_queue_t queue;
@end
@@ -22,6 +23,7 @@
if (self) {
_fileURL = [fileURL copy];
_queue = dispatch_queue_create("org.subler.LogQueue", DISPATCH_QUEUE_SERIAL);
}
return self;
@@ -38,22 +40,30 @@
}
- (void)writeToLog:(NSString *)string {
if (self.fileURL) {
FILE *f = fopen(self.fileURL.fileSystemRepresentation, "a");
if (f) {
fprintf(f, "%s %s", [self currentTime].UTF8String, string.UTF8String);
fclose(f);
dispatch_sync(self.queue, ^{
if (self.fileURL) {
FILE *f = fopen(self.fileURL.fileSystemRepresentation, "a");
if (f) {
fprintf(f, "%s %s", [self currentTime].UTF8String, string.UTF8String);
fprintf(f, "\n");
fclose(f);
}
}
}
if (self.delegate) {
[self.delegate writeToLog:[NSString stringWithFormat:@"%@ %@", [self currentTime], string]];
}
if (self.delegate) {
[self.delegate writeToLog:[NSString stringWithFormat:@"%@ %@", [self currentTime], string]];
[self.delegate writeToLog:@"\n"];
}
});
}
- (void)writeErrorToLog:(NSError *)error {
[self writeToLog:[NSString stringWithFormat:@"%@\n", error.localizedDescription]];
[self writeToLog:[NSString stringWithFormat:@"%@\n", error.localizedRecoverySuggestion]];
if (error.localizedDescription) {
[self writeToLog:error.localizedDescription];
}
if (error.localizedRecoverySuggestion) {
[self writeToLog:error.localizedRecoverySuggestion];
}
}
- (void)clearLog {