From 656cb824a32bd1f748e21791697a2a6779464681 Mon Sep 17 00:00:00 2001 From: German Laullon Date: Tue, 5 Apr 2011 11:39:01 -0700 Subject: [PATCH] NSLog => Dlog (Log only on debug build) --- ApplicationController.m | 4 ++-- GLFileView.m | 8 ++++---- GitX_Prefix.pch | 12 ++++++++++++ MGScopeBar/MGScopeBar.m | 8 ++++---- Model/PBGitSubmodule.m | 2 +- PBCloneRepsitoryToSheet.m | 2 +- PBCommitList.m | 12 ++++++------ PBDiffWindowController.m | 2 +- PBEasyPipe.h | 2 +- PBEasyPipe.m | 7 +++---- PBGitBinary.h | 1 + PBGitBinary.m | 4 ++-- PBGitConfig.m | 2 +- PBGitGrapher.mm | 2 +- PBGitHistoryGrapher.m | 2 +- PBGitRepository.m | 2 +- PBGitRevList.mm | 8 ++++---- PBGitSidebarController.m | 2 +- PBGitTree.m | 4 ++-- PBGitWindowController.m | 4 ++-- PBGitXProtocol.m | 4 ++-- PBRemoteProgressSheet.m | 2 +- PBWebController.m | 8 ++++---- PBWebHistoryController.m | 2 +- SearchWebView.m | 2 +- gitx_askpasswd_main.m | 2 +- 26 files changed, 61 insertions(+), 49 deletions(-) diff --git a/ApplicationController.m b/ApplicationController.m index c4681ea..ef3ef28 100644 --- a/ApplicationController.m +++ b/ApplicationController.m @@ -31,7 +31,7 @@ if(![[NSBundle bundleWithPath:@"/System/Library/Frameworks/Quartz.framework/Frameworks/QuickLookUI.framework"] load]) if(![[NSBundle bundleWithPath:@"/System/Library/PrivateFrameworks/QuickLookUI.framework"] load]) - NSLog(@"Could not load QuickLook"); + DLog(@"Could not load QuickLook"); /* Value Transformers */ NSValueTransformer *transformer = [[PBNSURLPathUserDefaultsTransfomer alloc] init]; @@ -55,7 +55,7 @@ int serviceVersion = [[NSUserDefaults standardUserDefaults] integerForKey:@"Services Version"]; if (serviceVersion < 2) { - NSLog(@"Updating services menu…"); + DLog(@"Updating services menu…"); NSUpdateDynamicServices(); [[NSUserDefaults standardUserDefaults] setInteger:2 forKey:@"Services Version"]; } diff --git a/GLFileView.m b/GLFileView.m index b4769ca..4ea3360 100644 --- a/GLFileView.m +++ b/GLFileView.m @@ -124,7 +124,7 @@ if(!theError){ NSString *filePath = [file fullPath]; fileTxt=[fileTxt stringByReplacingOccurrencesOfString:@"\t" withString:@"    "]; - NSLog(@"file.sha='%@'",file.sha); + DLog(@"file.sha='%@'",file.sha); fileTxt=[fileTxt stringByReplacingOccurrencesOfString:@"{SHA_PREV}" withString:file.sha]; if(diffType==@"h") { fileTxt=[fileTxt stringByReplacingOccurrencesOfString:@"{SHA}" withString:@"HEAD"]; @@ -372,7 +372,7 @@ int r_line,r_end; line=[lines nextObject]; - NSLog(@"-=%@=-",line); + DLog(@"-=%@=-",line); NSString *header=[line substringFromIndex:3]; NSRange hr = NSMakeRange(0, [header rangeOfString:@" @@"].location); header=[header substringWithRange:hr]; @@ -575,7 +575,7 @@ [res appendString:@"\n"]; } [res appendString:@"\n"]; - //NSLog(@"%@",res); + //DLog(@"%@",res); return (NSString *)res; } @@ -648,7 +648,7 @@ -(IBAction)updateSearch:(NSSearchField *)sender { NSString *searchString = [sender stringValue]; - NSLog(@"searchString:%@",searchString); + DLog(@"searchString:%@",searchString); if([searchString length]>0){ [view highlightAllOccurencesOfString:searchString]; diff --git a/GitX_Prefix.pch b/GitX_Prefix.pch index 3416e4a..f1ce03e 100644 --- a/GitX_Prefix.pch +++ b/GitX_Prefix.pch @@ -5,3 +5,15 @@ #ifdef __OBJC__ #import #endif + +#ifndef DLog +#ifdef DEBUG +# define DLog(...) NSLog(__VA_ARGS__) +#else +# define DLog(...) /* */ +#endif +#endif + +#ifndef ALog +#define ALog(...) DLog(__VA_ARGS__) +#endif diff --git a/MGScopeBar/MGScopeBar.m b/MGScopeBar/MGScopeBar.m index 28454e3..83c5789 100644 --- a/MGScopeBar/MGScopeBar.m +++ b/MGScopeBar/MGScopeBar.m @@ -451,11 +451,11 @@ // We're widening. See if we can expand this group and still be within availableWidth. if (((theoreticalOccupiedWidth - contractedWidth) + expandedWidth) > availableWidth) { // We'd be too wide if we expanded this group. Terminate iteration without updating _firstCollapsedGroup. - //NSLog(@"We'd be too wide if we expanded right now"); + //DLog(@"We'd be too wide if we expanded right now"); break; } // else, continue trying to expand groups. theoreticalOccupiedWidth = ((theoreticalOccupiedWidth - contractedWidth) + expandedWidth); - //NSLog(@"We can continue expanding"); + //DLog(@"We can continue expanding"); } // Update _firstCollapsedGroup appropriately. @@ -474,7 +474,7 @@ // Work out how many groups we need to actually change. NSRange changedRange = NSMakeRange(0, [_groups count]); BOOL adjusting = YES; - //NSLog(@"Old firstCollapsedGroup: %d, new: %d", oldFirstCollapsedGroup, _firstCollapsedGroup); + //DLog(@"Old firstCollapsedGroup: %d, new: %d", oldFirstCollapsedGroup, _firstCollapsedGroup); if (_firstCollapsedGroup != oldFirstCollapsedGroup) { if (narrower) { // Narrower. _firstCollapsedGroup will be less (earlier) than oldFirstCollapsedGroup. @@ -492,7 +492,7 @@ // If a change is required, ensure that each group is expanded or contracted as appropriate. if (adjusting || shouldAdjustPopups) { - //NSLog(@"Got %@ - modifying groups %@", ((narrower) ? @"narrower" : @"wider"), NSStringFromRange(changedRange)); + //DLog(@"Got %@ - modifying groups %@", ((narrower) ? @"narrower" : @"wider"), NSStringFromRange(changedRange)); NSInteger nextXCoord = NSNotFound; if (adjusting) { int i; diff --git a/Model/PBGitSubmodule.m b/Model/PBGitSubmodule.m index 56b1140..507070f 100644 --- a/Model/PBGitSubmodule.m +++ b/Model/PBGitSubmodule.m @@ -36,7 +36,7 @@ unichar status = [submoduleStatusString characterAtIndex:0]; submoduleState = [PBGitSubmodule submoduleStateFromCharacter:status]; if (submoduleState == PBGitSubmoduleStateFailed) { - NSLog(@"Submodule status failed:\n %@", submoduleStatusString); + DLog(@"Submodule status failed:\n %@", submoduleStatusString); return nil; } NSScanner *scanner = [NSScanner scannerWithString:[submoduleStatusString substringFromIndex:1]]; diff --git a/PBCloneRepsitoryToSheet.m b/PBCloneRepsitoryToSheet.m index f9c60d6..4d9a619 100644 --- a/PBCloneRepsitoryToSheet.m +++ b/PBCloneRepsitoryToSheet.m @@ -71,7 +71,7 @@ if (code == NSOKButton) { NSString *clonePath = [(NSOpenPanel *)sheet filename]; - NSLog(@"clone path = %@", clonePath); + DLog(@"clone path = %@", clonePath); [self.repository cloneRepositoryToPath:clonePath bare:self.isBare]; } } diff --git a/PBCommitList.m b/PBCommitList.m index dbf33b4..b9a58ae 100644 --- a/PBCommitList.m +++ b/PBCommitList.m @@ -63,7 +63,7 @@ // a little bit depending on how much the bottom half of the split view is dragged down. - (NSRect)adjustScroll:(NSRect)proposedVisibleRect { - //NSLog(@"[%@ %s]: proposedVisibleRect: %@", [self class], _cmd, NSStringFromRect(proposedVisibleRect)); + //DLog(@"[%@ %s]: proposedVisibleRect: %@", [self class], _cmd, NSStringFromRect(proposedVisibleRect)); NSRect newRect = proposedVisibleRect; // !!! Andre Berg 20100330: only modify if -scrollSelectionToTopOfViewFrom: has set useAdjustScroll to YES @@ -74,18 +74,18 @@ NSInteger adj = rh - ny; // check the targeted row and see if we need to add or subtract the difference (if there is one)... NSRect sr = [self rectOfRow:[self selectedRow]]; - // NSLog(@"[%@ %s]: selectedRow %d, rect: %@", [self class], _cmd, [self selectedRow], NSStringFromRect(sr)); + // DLog(@"[%@ %s]: selectedRow %d, rect: %@", [self class], _cmd, [self selectedRow], NSStringFromRect(sr)); if (sr.origin.y > proposedVisibleRect.origin.y) { - // NSLog(@"[%@ %s] selectedRow.origin.y > proposedVisibleRect.origin.y. adding adj (%d)", [self class], _cmd, adj); + // DLog(@"[%@ %s] selectedRow.origin.y > proposedVisibleRect.origin.y. adding adj (%d)", [self class], _cmd, adj); newRect = NSMakeRect(newRect.origin.x, newRect.origin.y + adj, newRect.size.width, newRect.size.height); } else if (sr.origin.y < proposedVisibleRect.origin.y) { - // NSLog(@"[%@ %s] selectedRow.origin.y < proposedVisibleRect.origin.y. subtracting ny (%d)", [self class], _cmd, ny); + // DLog(@"[%@ %s] selectedRow.origin.y < proposedVisibleRect.origin.y. subtracting ny (%d)", [self class], _cmd, ny); newRect = NSMakeRect(newRect.origin.x, newRect.origin.y - ny , newRect.size.width, newRect.size.height); } else { - // NSLog(@"[%@ %s] selectedRow.origin.y == proposedVisibleRect.origin.y. leaving as is", [self class], _cmd); + // DLog(@"[%@ %s] selectedRow.origin.y == proposedVisibleRect.origin.y. leaving as is", [self class], _cmd); } } - //NSLog(@"[%@ %s]: newRect: %@", [self class], _cmd, NSStringFromRect(newRect)); + //DLog(@"[%@ %s]: newRect: %@", [self class], _cmd, NSStringFromRect(newRect)); return newRect; } diff --git a/PBDiffWindowController.m b/PBDiffWindowController.m index ae545d9..4aacfe2 100644 --- a/PBDiffWindowController.m +++ b/PBDiffWindowController.m @@ -47,7 +47,7 @@ int retValue; NSString *diff = [startCommit.repository outputInWorkdirForArguments:arguments retValue:&retValue]; if (retValue) { - NSLog(@"diff failed with retValue: %d for command: '%@' output: '%@'", retValue, [arguments componentsJoinedByString:@" "], diff); + DLog(@"diff failed with retValue: %d for command: '%@' output: '%@'", retValue, [arguments componentsJoinedByString:@" "], diff); return; } diff --git a/PBEasyPipe.h b/PBEasyPipe.h index 84793ee..94ed673 100644 --- a/PBEasyPipe.h +++ b/PBEasyPipe.h @@ -7,7 +7,7 @@ // #import - +#import "GitX_Prefix.pch" @interface PBEasyPipe : NSObject { diff --git a/PBEasyPipe.m b/PBEasyPipe.m index fe8efa8..da5c577 100644 --- a/PBEasyPipe.m +++ b/PBEasyPipe.m @@ -8,7 +8,6 @@ #import "PBEasyPipe.h" - @implementation PBEasyPipe + (NSFileHandle*) handleForCommand: (NSString*) cmd withArgs: (NSArray*) args @@ -33,9 +32,9 @@ [task setCurrentDirectoryPath:dir]; if ([[NSUserDefaults standardUserDefaults] boolForKey:@"Show Debug Messages"]) - NSLog(@"Starting command `%@ %@` in dir %@", cmd, [args componentsJoinedByString:@" "], dir); + DLog(@"Starting command `%@ %@` in dir %@", cmd, [args componentsJoinedByString:@" "], dir); #ifdef CLI - NSLog(@"Starting command `%@ %@` in dir %@", cmd, [args componentsJoinedByString:@" "], dir); + DLog(@"Starting command `%@ %@` in dir %@", cmd, [args componentsJoinedByString:@" "], dir); #endif NSPipe* pipe = [NSPipe pipe]; @@ -128,7 +127,7 @@ data = [handle readDataToEndOfFile]; } @catch (NSException * e) { - NSLog(@"Got a bad file descriptor in %@!", NSStringFromSelector(_cmd)); + DLog(@"Got a bad file descriptor in %@!", NSStringFromSelector(_cmd)); if ([NSThread currentThread] != [NSThread mainThread]) [task waitUntilExit]; diff --git a/PBGitBinary.h b/PBGitBinary.h index 5008b3d..3ec9ce0 100644 --- a/PBGitBinary.h +++ b/PBGitBinary.h @@ -7,6 +7,7 @@ // #import +#import "GitX_Prefix.pch" #define MIN_GIT_VERSION "1.6.0" diff --git a/PBGitBinary.m b/PBGitBinary.m index 6b1a488..b939044 100644 --- a/PBGitBinary.m +++ b/PBGitBinary.m @@ -43,7 +43,7 @@ static NSString* gitPath = nil; return YES; } - NSLog(@"Found a git binary at %@, but is only version %@", path, version); + DLog(@"Found a git binary at %@, but is only version %@", path, version); return NO; } @@ -80,7 +80,7 @@ static NSString* gitPath = nil; return; } - NSLog(@"Could not find a git binary higher than version " MIN_GIT_VERSION); + DLog(@"Could not find a git binary higher than version " MIN_GIT_VERSION); } + (NSString *) path; diff --git a/PBGitConfig.m b/PBGitConfig.m index 4bdbbc7..93e38d6 100644 --- a/PBGitConfig.m +++ b/PBGitConfig.m @@ -41,7 +41,7 @@ int ret; [PBEasyPipe outputForCommand:[PBGitBinary path] withArgs:array inDir:nil retValue:&ret]; if (ret) - NSLog(@"Writing to config file failed!"); + DLog(@"Writing to config file failed!"); [self didChangeValueForKey:[key substringToIndex:[key rangeOfString:@"."].location]]; } diff --git a/PBGitGrapher.mm b/PBGitGrapher.mm index 41401d6..d22ba6c 100644 --- a/PBGitGrapher.mm +++ b/PBGitGrapher.mm @@ -137,7 +137,7 @@ void add_line(struct PBGitGraphLine *lines, int *nLines, int upper, int from, in previous = [[PBGraphCellInfo alloc] initWithPosition:newPos andLines:lines]; if (currentLine > maxLines) - NSLog(@"Number of lines: %i vs allocated: %i", currentLine, maxLines); + DLog(@"Number of lines: %i vs allocated: %i", currentLine, maxLines); previous.nLines = currentLine; previous.sign = commit.sign; diff --git a/PBGitHistoryGrapher.m b/PBGitHistoryGrapher.m index ab9760d..062c7ae 100644 --- a/PBGitHistoryGrapher.m +++ b/PBGitHistoryGrapher.m @@ -65,7 +65,7 @@ } } //NSTimeInterval duration = [[NSDate date] timeIntervalSinceDate:start]; - //NSLog(@"Graphed %i commits in %f seconds (%f/sec)", counter, duration, counter/duration); + //DLog(@"Graphed %i commits in %f seconds (%f/sec)", counter, duration, counter/duration); [self sendCommits:commits]; [delegate performSelectorOnMainThread:@selector(finishedGraphing) withObject:nil waitUntilDone:NO]; diff --git a/PBGitRepository.m b/PBGitRepository.m index 0ca06a6..41bc6f0 100644 --- a/PBGitRepository.m +++ b/PBGitRepository.m @@ -1282,7 +1282,7 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; - (void) finalize { - //NSLog(@"Dealloc of repository"); + //DLog(@"Dealloc of repository"); [super finalize]; } @end diff --git a/PBGitRevList.mm b/PBGitRevList.mm index 18fcdf7..58992bf 100644 --- a/PBGitRevList.mm +++ b/PBGitRevList.mm @@ -165,7 +165,7 @@ using namespace std; if (parentString.size() != 0) { if (((parentString.size() + 1) % 41) != 0) { - NSLog(@"invalid parents: %zu", parentString.size()); + DLog(@"invalid parents: %zu", parentString.size()); continue; } int nParents = (parentString.size() + 1) / 41; @@ -191,7 +191,7 @@ using namespace std; stream >> c; // Remove separator stream >> c; if (c != '>' && c != '<' && c != '^' && c != '-') - NSLog(@"Error loading commits: sign not correct"); + DLog(@"Error loading commits: sign not correct"); [newCommit setSign: c]; } @@ -216,7 +216,7 @@ using namespace std; if (![currentThread isCancelled]) { NSTimeInterval duration = [[NSDate date] timeIntervalSinceDate:start]; - NSLog(@"Loaded %i commits in %f seconds (%f/sec)", num, duration, num/duration); + DLog(@"Loaded %i commits in %f seconds (%f/sec)", num, duration, num/duration); // Make sure the commits are stored before exiting. NSDictionary *update = [NSDictionary dictionaryWithObjectsAndKeys:currentThread, kRevListThreadKey, revisions, kRevListRevisionsKey, nil]; @@ -225,7 +225,7 @@ using namespace std; [self performSelectorOnMainThread:@selector(finishedParsing) withObject:nil waitUntilDone:NO]; } else { - NSLog(@"[%@ %@] thread has been canceled", [self class], NSStringFromSelector(_cmd)); + DLog(@"[%@ %@] thread has been canceled", [self class], NSStringFromSelector(_cmd)); } [task terminate]; diff --git a/PBGitSidebarController.m b/PBGitSidebarController.m index a9a936e..c3b2e47 100644 --- a/PBGitSidebarController.m +++ b/PBGitSidebarController.m @@ -170,7 +170,7 @@ static NSString * const kObservingContextSubmodules = @"submodulesChanged"; -(void)evaluateRemoteBadge:(PBGitSVRemoteItem *)remote { - NSLog(@"remote.title=%@",[remote title]); + DLog(@"remote.title=%@",[remote title]); [remote setAlert:[self remoteNeedFetch:[remote title]]]; } diff --git a/PBGitTree.m b/PBGitTree.m index dee9114..8c33b73 100644 --- a/PBGitTree.m +++ b/PBGitTree.m @@ -221,12 +221,12 @@ } res=[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff", sha, des,[self fullPath], nil]]; if ([res length]==0) { - NSLog(@"--%@",[res length]); + DLog(@"--%@",[res length]); if (anError != NULL) { *anError = [NSError errorWithDomain:@"diff" code:1 userInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"No Diff",NSLocalizedDescriptionKey,nil]]; } }else{ - NSLog(@"--%@",[res substringToIndex:80]); + DLog(@"--%@",[res substringToIndex:80]); } }else{ if (anError != NULL) { diff --git a/PBGitWindowController.m b/PBGitWindowController.m index 294fb23..929bf61 100644 --- a/PBGitWindowController.m +++ b/PBGitWindowController.m @@ -33,7 +33,7 @@ - (void)windowWillClose:(NSNotification *)notification { - //NSLog(@"Window will close!"); + //DLog(@"Window will close!"); if (sidebarController) [sidebarController closeView]; @@ -226,7 +226,7 @@ sp=[[sidebarController historyViewController] historySplitView]; break; } - NSLog(@"sp=%@",sp); + DLog(@"sp=%@",sp); if(sp!=nil) { [self collapseSplitView:sp show:[sender isSelectedForSegment:[sender selectedSegment]]]; } diff --git a/PBGitXProtocol.m b/PBGitXProtocol.m index ae06283..ea0e682 100644 --- a/PBGitXProtocol.m +++ b/PBGitXProtocol.m @@ -47,10 +47,10 @@ if ([[url host] isEqualToString:@"app"]) { NSString *app=[[url path] substringFromIndex:1]; NSString *appPath=[[NSWorkspace sharedWorkspace] fullPathForApplication:app]; - NSLog(@"app=%@ appPath=%@",app,appPath); + DLog(@"app=%@ appPath=%@",app,appPath); if(appPath){ NSImage *icon = [[NSWorkspace sharedWorkspace] iconForFile:appPath]; - NSLog(@"icon=%@",icon); + DLog(@"icon=%@",icon); [[self client] URLProtocol:self didLoadData:[icon TIFFRepresentation]]; [[self client] URLProtocolDidFinishLoading:self]; }else{ diff --git a/PBRemoteProgressSheet.m b/PBRemoteProgressSheet.m index 0160431..39414ec 100644 --- a/PBRemoteProgressSheet.m +++ b/PBRemoteProgressSheet.m @@ -130,7 +130,7 @@ NSString * const kGitXProgressErrorInfo = @"PBGitXProgressErrorInfo"; - (void) checkTask:(NSTimer *)timer { if (![gitTask isRunning]) { - NSLog(@"[%@ %@] gitTask terminated without notification", [self class], NSStringFromSelector(_cmd)); + DLog(@"[%@ %@] gitTask terminated without notification", [self class], NSStringFromSelector(_cmd)); [self taskCompleted:nil]; } } diff --git a/PBWebController.m b/PBWebController.m index 7c18db8..f6cbee9 100644 --- a/PBWebController.m +++ b/PBWebController.m @@ -73,12 +73,12 @@ - (void)webView:(WebView *)webView addMessageToConsole:(NSDictionary *)dictionary { - NSLog(@"Error from webkit: %@", dictionary); + DLog(@"Error from webkit: %@", dictionary); } - (void)webView:(WebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame { - NSLog(@"Message from webkit: %@", message); + DLog(@"Message from webkit: %@", message); } - (NSURLRequest *)webView:(WebView *)sender @@ -114,7 +114,7 @@ - (void) log: (NSString*) logMessage { - NSLog(@"%@", logMessage); + DLog(@"%@", logMessage); } - (BOOL) isReachable:(NSString *)hostname @@ -189,7 +189,7 @@ { WebScriptObject *a = [callbacks objectForKey: object]; if (!a) { - NSLog(@"Could not find a callback for object: %@", object); + DLog(@"Could not find a callback for object: %@", object); return; } diff --git a/PBWebHistoryController.m b/PBWebHistoryController.m index 5c74df5..b422132 100644 --- a/PBWebHistoryController.m +++ b/PBWebHistoryController.m @@ -262,7 +262,7 @@ contextMenuItemsForElement:(NSDictionary *)element if ([[ref shortName] isEqualToString:selectedRefString]) return [contextMenuDelegate menuItemsForRef:ref]; } - NSLog(@"Could not find selected ref!"); + DLog(@"Could not find selected ref!"); return defaultMenuItems; } if ([node hasAttributes] && [[node attributes] getNamedItem:@"representedFile"]) diff --git a/SearchWebView.m b/SearchWebView.m index 6718a94..5a21e40 100644 --- a/SearchWebView.m +++ b/SearchWebView.m @@ -42,7 +42,7 @@ }else if([node nodeType]==DOM_ELEMENT_NODE){ count+=[self highlightAllOccurencesOfString:str inNode:node]; }else{ - NSLog(@"--->%@",node); + DLog(@"--->%@",node); } node=[node nextSibling]; } diff --git a/gitx_askpasswd_main.m b/gitx_askpasswd_main.m index 12fcc93..a2d65ba 100644 --- a/gitx_askpasswd_main.m +++ b/gitx_askpasswd_main.m @@ -336,7 +336,7 @@ int main( int argc, const char* argv[] ) SecKeychainItemFreeContent (NULL,passwordData); NSString *pas=[[NSString stringWithCString:passwordData encoding:NSASCIIStringEncoding] substringToIndex:passwordLength]; printf( "%s", [pas UTF8String] ); - //NSLog(@"--> '%@'",pas); + //DLog(@"--> '%@'",pas); return 0; }else if (status != errSecItemNotFound) { return -1;