Add some additional log messages to track down a tvdb issue.
This commit is contained in:
1 parent
7721818507
commit
3d285f692f
5 files changed
+42
-5
No files matched your search
@@ -7,6 +7,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
#import <MP42Foundation/MP42Logging.h>
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@@ -22,6 +23,8 @@ typedef NS_ENUM(NSUInteger, SBCachePolicy) {
|
|||||||
+ (nullable NSDictionary<NSString *, NSString *> *)parseFilename:(NSString *)filename;
|
+ (nullable NSDictionary<NSString *, NSString *> *)parseFilename:(NSString *)filename;
|
||||||
+ (NSString *)urlEncoded:(NSString *)string;
|
+ (NSString *)urlEncoded:(NSString *)string;
|
||||||
|
|
||||||
|
@property (class) id<MP42Logging> logger;
|
||||||
|
|
||||||
+ (nullable NSData *)downloadDataFromURL:(NSURL *)url cachePolicy:(SBCachePolicy)policy;
|
+ (nullable NSData *)downloadDataFromURL:(NSURL *)url cachePolicy:(SBCachePolicy)policy;
|
||||||
+ (nullable NSData *)downloadDataFromURL:(NSURL *)url HTTPMethod:(NSString *)method HTTPBody:(nullable NSData *)body headerOptions:(nullable NSDictionary *)header cachePolicy:(SBCachePolicy)policy;
|
+ (nullable NSData *)downloadDataFromURL:(NSURL *)url HTTPMethod:(NSString *)method HTTPBody:(nullable NSData *)body headerOptions:(nullable NSDictionary *)header cachePolicy:(SBCachePolicy)policy;
|
||||||
+ (NSURLSessionTask *)sessionTaskFromUrl:(NSURL *)url HTTPMethod:(NSString *)method HTTPBody:(nullable NSData *)body headerOptions:(nullable NSDictionary *)header cachePolicy:(NSURLRequestCachePolicy)cachePolicy completionHandler:(void(^)(NSData * _Nullable data))completionHandler;
|
+ (NSURLSessionTask *)sessionTaskFromUrl:(NSURL *)url HTTPMethod:(NSString *)method HTTPBody:(nullable NSData *)body headerOptions:(nullable NSDictionary *)header cachePolicy:(NSURLRequestCachePolicy)cachePolicy completionHandler:(void(^)(NSData * _Nullable data))completionHandler;
|
||||||
|
|||||||
@@ -9,8 +9,20 @@
|
|||||||
#import "SBMetadataHelper.h"
|
#import "SBMetadataHelper.h"
|
||||||
#import <CommonCrypto/CommonDigest.h>
|
#import <CommonCrypto/CommonDigest.h>
|
||||||
|
|
||||||
|
static id<MP42Logging> _logger;
|
||||||
|
|
||||||
@implementation SBMetadataHelper
|
@implementation SBMetadataHelper
|
||||||
|
|
||||||
|
+ (void)setLogger:(id<MP42Logging>)logger
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (id<MP42Logging>)logger
|
||||||
|
{
|
||||||
|
return _logger;
|
||||||
|
}
|
||||||
|
|
||||||
+ (nullable NSDictionary<NSString *, NSString *> *)parseFilename:(NSString *)filename
|
+ (nullable NSDictionary<NSString *, NSString *> *)parseFilename:(NSString *)filename
|
||||||
{
|
{
|
||||||
NSParameterAssert(filename);
|
NSParameterAssert(filename);
|
||||||
@@ -195,8 +207,11 @@
|
|||||||
request.HTTPBody = body;
|
request.HTTPBody = body;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[_logger writeToLog:[NSString stringWithFormat:@"Requesting URL %@", url.absoluteString]];
|
||||||
|
|
||||||
NSURLSession *defaultSession = [NSURLSession sharedSession];
|
NSURLSession *defaultSession = [NSURLSession sharedSession];
|
||||||
NSURLSessionTask *task = [defaultSession dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
|
NSURLSessionTask *task = [defaultSession dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
NSUInteger statusCode = 0;
|
NSUInteger statusCode = 0;
|
||||||
if ([response isKindOfClass:[NSHTTPURLResponse class]]) {
|
if ([response isKindOfClass:[NSHTTPURLResponse class]]) {
|
||||||
@@ -207,9 +222,17 @@
|
|||||||
completionHandler(data);
|
completionHandler(data);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
NSString *errorData = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
|
||||||
|
if (errorData) {
|
||||||
|
[_logger writeToLog:errorData];
|
||||||
|
}
|
||||||
completionHandler(nil);
|
completionHandler(nil);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
[_logger writeErrorToLog:error];
|
||||||
|
}
|
||||||
}];
|
}];
|
||||||
|
|
||||||
return task;
|
return task;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#import "SBQueueController.h"
|
#import "SBQueueController.h"
|
||||||
#import "SBPrefsController.h"
|
#import "SBPrefsController.h"
|
||||||
#import "SBLogWindowController.h"
|
#import "SBLogWindowController.h"
|
||||||
|
#import "SBMetadataHelper.h"
|
||||||
#import "SBLogger.h"
|
#import "SBLogger.h"
|
||||||
|
|
||||||
#import <MP42Foundation/MP42File.h>
|
#import <MP42Foundation/MP42File.h>
|
||||||
@@ -49,8 +50,8 @@
|
|||||||
[logger clearLog];
|
[logger clearLog];
|
||||||
|
|
||||||
debugLogController = [[SBLogWindowController alloc] initWithLogger:logger];
|
debugLogController = [[SBLogWindowController alloc] initWithLogger:logger];
|
||||||
[MP42File setGlobalLogger:logger];
|
MP42File.globalLogger = logger;
|
||||||
|
SBMetadataHelper.logger = logger;
|
||||||
|
|
||||||
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"SBShowQueueWindow"]) {
|
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"SBShowQueueWindow"]) {
|
||||||
[[SBQueueController sharedManager] showWindow:self];
|
[[SBQueueController sharedManager] showWindow:self];
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
- (void)writeToLog:(NSString *)string {
|
- (void)writeToLog:(NSString *)string {
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:string];
|
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:string];
|
||||||
[(self.logView).textStorage appendAttributedString:attributedString];
|
[self.logView.textStorage appendAttributedString:attributedString];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+12
-2
@@ -12,6 +12,7 @@
|
|||||||
@interface SBLogger ()
|
@interface SBLogger ()
|
||||||
|
|
||||||
@property (nonatomic, readonly) NSURL *fileURL;
|
@property (nonatomic, readonly) NSURL *fileURL;
|
||||||
|
@property (nonatomic, readonly) dispatch_queue_t queue;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@@ -22,6 +23,7 @@
|
|||||||
|
|
||||||
if (self) {
|
if (self) {
|
||||||
_fileURL = [fileURL copy];
|
_fileURL = [fileURL copy];
|
||||||
|
_queue = dispatch_queue_create("org.subler.LogQueue", DISPATCH_QUEUE_SERIAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
@@ -38,22 +40,30 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)writeToLog:(NSString *)string {
|
- (void)writeToLog:(NSString *)string {
|
||||||
|
dispatch_sync(self.queue, ^{
|
||||||
if (self.fileURL) {
|
if (self.fileURL) {
|
||||||
FILE *f = fopen(self.fileURL.fileSystemRepresentation, "a");
|
FILE *f = fopen(self.fileURL.fileSystemRepresentation, "a");
|
||||||
if (f) {
|
if (f) {
|
||||||
fprintf(f, "%s %s", [self currentTime].UTF8String, string.UTF8String);
|
fprintf(f, "%s %s", [self currentTime].UTF8String, string.UTF8String);
|
||||||
|
fprintf(f, "\n");
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self.delegate) {
|
if (self.delegate) {
|
||||||
[self.delegate writeToLog:[NSString stringWithFormat:@"%@ %@", [self currentTime], string]];
|
[self.delegate writeToLog:[NSString stringWithFormat:@"%@ %@", [self currentTime], string]];
|
||||||
|
[self.delegate writeToLog:@"\n"];
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)writeErrorToLog:(NSError *)error {
|
- (void)writeErrorToLog:(NSError *)error {
|
||||||
[self writeToLog:[NSString stringWithFormat:@"%@\n", error.localizedDescription]];
|
if (error.localizedDescription) {
|
||||||
[self writeToLog:[NSString stringWithFormat:@"%@\n", error.localizedRecoverySuggestion]];
|
[self writeToLog:error.localizedDescription];
|
||||||
|
}
|
||||||
|
if (error.localizedRecoverySuggestion) {
|
||||||
|
[self writeToLog:error.localizedRecoverySuggestion];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)clearLog {
|
- (void)clearLog {
|
||||||
|
|||||||
Reference in new issue
Block a user