Commit 61486f35 authored by Felix Paul Kühne's avatar Felix Paul Kühne

MLKit: introduce the APLog makro so we don't spam release builds with debug messages

parent 5e775404
......@@ -19,3 +19,9 @@
#endif
#import "NSXMLNode_Additions.h"
#ifndef NDEBUG
#define APLog(format, ...) NSLog(format, ## __VA_ARGS__)
#else
#define APLog(format, ...)
#endif
\ No newline at end of file
......@@ -46,7 +46,7 @@
- (void)cancelAllFileParse
{
NSLog(@"Cancelling file parsing");
APLog(@"Cancelling file parsing");
for (MLFile *file in _parsedFiles)
file.isBeingParsed = NO;
[_parsedFiles removeAllObjects];
......
......@@ -43,7 +43,7 @@ NSString *kMLFileTypeTVShowEpisode = @"tvShowEpisode";
[request release];
[descriptor release];
if (!movies) {
NSLog(@"WARNING: %@", error);
APLog(@"WARNING: %@", error);
}
return movies;
......
......@@ -44,7 +44,7 @@
{
NSAssert(!_media, @"We are already parsing");
NSLog(@"Starting parsing %@", self.file);
APLog(@"Starting parsing %@", self.file);
[[MLCrashPreventer sharedPreventer] willParseFile:self.file];
_media = [[VLCMedia mediaWithURL:[NSURL URLWithString:self.file.url]] retain];
......@@ -62,7 +62,7 @@
- (void)mediaDidFinishParsing:(VLCMedia *)media
{
NSLog(@"Parsed %@ - %d tracks", media, [[_media tracksInformation] count]);
APLog(@"Parsed %@ - %d tracks", media, [[_media tracksInformation] count]);
if (_media.delegate != self)
return;
......@@ -144,7 +144,7 @@ static inline NSString *hashFromFile(MLFile *file)
if ([_fileDescriptionToOperation objectForKey:hashFromFile(file)])
return;
if (![[MLCrashPreventer sharedPreventer] isFileSafe:file]) {
NSLog(@"%@ is unsafe and will crash, ignoring", file);
APLog(@"%@ is unsafe and will crash, ignoring", file);
return;
}
MLParsingOperation *op = [[MLParsingOperation alloc] initWithFile:file];
......
......@@ -27,8 +27,6 @@
#import <UIKit/UIKit.h>
#endif
#define MLLog(...) NSLog(__VA_ARGS__)
// Pref key
static NSString *kLastTVDBUpdateServerTime = @"MLLastTVDBUpdateServerTime";
......@@ -48,7 +46,7 @@ static NSString *kLastTVDBUpdateServerTime = @"MLLastTVDBUpdateServerTime";
static id sharedMediaLibrary = nil;
if (!sharedMediaLibrary) {
sharedMediaLibrary = [[[self class] alloc] init];
NSLog(@"Initializing db in %@", [sharedMediaLibrary databaseFolderPath]);
APLog(@"Initializing db in %@", [sharedMediaLibrary databaseFolderPath]);
// Also force to init the crash preventer
// Because it will correctly set up the parser and thumbnail queue
......@@ -196,13 +194,13 @@ static NSString *kLastTVDBUpdateServerTime = @"MLLastTVDBUpdateServerTime";
- (void)computeThumbnailForFile:(MLFile *)file
{
if (!file.computedThumbnail) {
MLLog(@"Computing thumbnail for %@", file.title);
APLog(@"Computing thumbnail for %@", file.title);
[[MLThumbnailerQueue sharedThumbnailerQueue] addFile:file];
}
}
- (void)errorWhenFetchingMetaDataForFile:(MLFile *)file
{
MLLog(@"Error when fetching for '%@'", file.title);
APLog(@"Error when fetching for '%@'", file.title);
[self computeThumbnailForFile:file];
}
......@@ -325,7 +323,7 @@ static NSString *kLastTVDBUpdateServerTime = @"MLLastTVDBUpdateServerTime";
showInfoGrabber.delegate = self;
showInfoGrabber.userData = show;
MLLog(@"Fetching show information on %@", show.name);
APLog(@"Fetching show information on %@", show.name);
[showInfoGrabber lookUpForTitle:show.name];
}
......@@ -335,7 +333,7 @@ static NSString *kLastTVDBUpdateServerTime = @"MLLastTVDBUpdateServerTime";
{
if (!_allowNetworkAccess)
return;
MLLog(@"Fetching show server time");
APLog(@"Fetching show server time");
// First fetch the serverTime, so that we can update each entry.
#if HAVE_BLOCK
......@@ -343,7 +341,7 @@ static NSString *kLastTVDBUpdateServerTime = @"MLLastTVDBUpdateServerTime";
[[NSUserDefaults standardUserDefaults] setInteger:[serverDate integerValue] forKey:kLastTVDBUpdateServerTime];
MLLog(@"Fetching show information on %@", show.name);
APLog(@"Fetching show information on %@", show.name);
// First fetch the MLShow ID
MLTVShowInfoGrabber *grabber = [[[MLTVShowInfoGrabber alloc] init] autorelease];
......@@ -358,7 +356,7 @@ static NSString *kLastTVDBUpdateServerTime = @"MLLastTVDBUpdateServerTime";
show.shortSummary = [result objectForKey:@"shortSummary"];
show.releaseYear = [result objectForKey:@"releaseYear"];
MLLog(@"Fetching show episode information on %@", showId);
APLog(@"Fetching show episode information on %@", showId);
// Fetch episode info
MLTVShowEpisodesInfoGrabber *grabber = [[[MLTVShowEpisodesInfoGrabber alloc] init] autorelease];
......@@ -465,7 +463,7 @@ static NSString *kLastTVDBUpdateServerTime = @"MLLastTVDBUpdateServerTime";
- (void)fetchMetaDataForFile:(MLFile *)file
{
MLLog(@"Fetching meta data for %@", file.title);
APLog(@"Fetching meta data for %@", file.title);
[[MLFileParserQueue sharedFileParserQueue] addFile:file];
......@@ -489,7 +487,7 @@ static NSString *kLastTVDBUpdateServerTime = @"MLLastTVDBUpdateServerTime";
// because we are a singleton
MLMovieInfoGrabber *grabber = [[[MLMovieInfoGrabber alloc] init] autorelease];
MLLog(@"Looking up for Movie '%@'", file.title);
APLog(@"Looking up for Movie '%@'", file.title);
#if HAVE_BLOCK
[grabber lookUpForTitle:file.title andExecuteBlock:^(NSError *err){
......@@ -523,7 +521,7 @@ static NSString *kLastTVDBUpdateServerTime = @"MLLastTVDBUpdateServerTime";
- (void)addFilePath:(NSString *)filePath
{
MLLog(@"Adding Path %@", filePath);
APLog(@"Adding Path %@", filePath);
NSURL *url = [NSURL fileURLWithPath:filePath];
NSDictionary *attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:nil];
......@@ -584,9 +582,9 @@ static NSString *kLastTVDBUpdateServerTime = @"MLLastTVDBUpdateServerTime";
[request setPredicate:[NSCompoundPredicate orPredicateWithSubpredicates:fetchPredicates]];
MLLog(@"Fetching");
APLog(@"Fetching");
NSArray *dbResults = [[self managedObjectContext] executeFetchRequest:request error:nil];
MLLog(@"Done");
APLog(@"Done");
NSMutableArray *filePathsToAdd = [NSMutableArray arrayWithArray:filepaths];
......@@ -634,7 +632,7 @@ static NSString *kLastTVDBUpdateServerTime = @"MLLastTVDBUpdateServerTime";
NSURL *fileURL = [NSURL URLWithString:urlString];
BOOL exists = [fileManager fileExistsAtPath:[fileURL path]];
if (!exists) {
NSLog(@"Marking - %@", [fileURL absoluteString]);
APLog(@"Marking - %@", [fileURL absoluteString]);
file.isSafe = YES; // It doesn't exists, it's safe.
}
file.isOnDisk = [NSNumber numberWithBool:exists];
......
......@@ -77,9 +77,9 @@
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
NSLog(@"Did Fail %@", _delegate);
APLog(@"Did Fail %@", _delegate);
if ([_delegate respondsToSelector:@selector(movieInfoGrabber:didFailWithError:)]) {
NSLog(@"Did Fail Calling %@", _delegate);
APLog(@"Did Fail Calling %@", _delegate);
[_delegate movieInfoGrabber:self didFailWithError:error];
}
......@@ -130,8 +130,8 @@
}
//NSLog(@"%@", title);
//NSLog(TMDB_QUERY_INFO, TMDB_HOSTNAME, id, TMDB_API_KEY);
//APLog(@"%@", title);
//APLog(TMDB_QUERY_INFO, TMDB_HOSTNAME, id, TMDB_API_KEY);
NSString *artworkURL = [node stringValueForXPath:@"./poster[size='cover']"];
if (!artworkURL)
artworkURL = [node stringValueForXPath:@"./poster"];
......
......@@ -44,7 +44,7 @@
- (void)fetchThumbnail
{
NSLog(@"Starting THUMB %@", self.file);
APLog(@"Starting THUMB %@", self.file);
[[MLCrashPreventer sharedPreventer] willParseFile:self.file];
......@@ -88,7 +88,7 @@
- (void)mediaThumbnailer:(VLCMediaThumbnailer *)mediaThumbnailer didFinishThumbnail:(CGImageRef)thumbnail
{
mediaThumbnailer.delegate = nil;
NSLog(@"Finished thumbnail for %@", self.file.title);
APLog(@"Finished thumbnail for %@", self.file.title);
self.file.computedThumbnail = [UIImage imageWithCGImage:thumbnail];
[self endThumbnailing];
......@@ -146,7 +146,7 @@ static inline NSString *hashFromFile(MLFile *file)
if ([_fileDescriptionToOperation objectForKey:hashFromFile(file)])
return;
if (![[MLCrashPreventer sharedPreventer] isFileSafe:file]) {
NSLog(@"'%@' is unsafe and will crash, ignoring", file.title);
APLog(@"'%@' is unsafe and will crash, ignoring", file.title);
return;
}
ThumbnailOperation *op = [[ThumbnailOperation alloc] initWithFile:file];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment