From 94a329b38a11a24c5f41372d7a1fe8b99919d73f Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Sat, 26 Jan 2013 19:17:58 +0000 Subject: [PATCH] update Mac code for logging changes in r13868 --- Transmission.xcodeproj/project.pbxproj | 8 ++++++++ macosx/Controller.m | 2 +- macosx/MessageWindowController.m | 28 +++++++++++++------------- macosx/Torrent.m | 6 +++--- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/Transmission.xcodeproj/project.pbxproj b/Transmission.xcodeproj/project.pbxproj index 2c3dcf854..2e8a99004 100644 --- a/Transmission.xcodeproj/project.pbxproj +++ b/Transmission.xcodeproj/project.pbxproj @@ -269,6 +269,8 @@ A2AB76EA15D8130B009EFC95 /* libcurl.4.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = A2290D2D1442B23200B95A09 /* libcurl.4.dylib */; }; A2AB883E16A399A6008FAD50 /* VDKQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = A2AB883C16A399A6008FAD50 /* VDKQueue.m */; }; A2AF1C390A3D0F6200F1575D /* FileOutlineView.m in Sources */ = {isa = PBXBuildFile; fileRef = A2AF1C370A3D0F6200F1575D /* FileOutlineView.m */; }; + A2AF23C816B44FA0003BC59E /* log.c in Sources */ = {isa = PBXBuildFile; fileRef = A2AF23C616B44FA0003BC59E /* log.c */; }; + A2AF23C916B44FA0003BC59E /* log.h in Headers */ = {isa = PBXBuildFile; fileRef = A2AF23C716B44FA0003BC59E /* log.h */; }; A2B3FB460E5901E700FF78FB /* cli.c in Sources */ = {isa = PBXBuildFile; fileRef = A2B3FB450E5901E700FF78FB /* cli.c */; }; A2B3FB4C0E59023000FF78FB /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; }; A2B3FB530E59027100FF78FB /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; }; @@ -974,6 +976,8 @@ A2AC81D60D987E2D00A2878C /* nl */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = nl; path = macosx/nl.lproj/AddWindow.xib; sourceTree = ""; }; A2AF1C360A3D0F6200F1575D /* FileOutlineView.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = FileOutlineView.h; path = macosx/FileOutlineView.h; sourceTree = ""; }; A2AF1C370A3D0F6200F1575D /* FileOutlineView.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = FileOutlineView.m; path = macosx/FileOutlineView.m; sourceTree = ""; }; + A2AF23C616B44FA0003BC59E /* log.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = log.c; path = libtransmission/log.c; sourceTree = ""; }; + A2AF23C716B44FA0003BC59E /* log.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = log.h; path = libtransmission/log.h; sourceTree = ""; }; A2B3FB450E5901E700FF78FB /* cli.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = cli.c; path = cli/cli.c; sourceTree = ""; }; A2B5BB7A0D9C7C2300FCB650 /* es */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = es; path = macosx/es.lproj/AddWindow.xib; sourceTree = ""; }; A2B6141B1395ADE9000E0975 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; }; @@ -1728,6 +1732,8 @@ A25BFD68167BED3B0039D1AA /* variant.h */, A2EA522F1686AC0D00180493 /* quark.c */, A2EA52301686AC0D00180493 /* quark.h */, + A2AF23C616B44FA0003BC59E /* log.c */, + A2AF23C716B44FA0003BC59E /* log.h */, A2A4EA0B0DE106E8000CE197 /* ConvertUTF.h */, A2A4EA0A0DE106E8000CE197 /* ConvertUTF.c */, 4DB74F070E8CD75100AEB1A8 /* wildmat.c */, @@ -2069,6 +2075,7 @@ A25BFD6A167BED3B0039D1AA /* variant-common.h in Headers */, A25BFD6E167BED3B0039D1AA /* variant.h in Headers */, A2EA52321686AC0D00180493 /* quark.h in Headers */, + A2AF23C916B44FA0003BC59E /* log.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2676,6 +2683,7 @@ A25BFD6B167BED3B0039D1AA /* variant-json.c in Sources */, A25BFD6D167BED3B0039D1AA /* variant.c in Sources */, A2EA52311686AC0D00180493 /* quark.c in Sources */, + A2AF23C816B44FA0003BC59E /* log.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/macosx/Controller.m b/macosx/Controller.m index dbee41602..b86a701e8 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -279,7 +279,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy stringByExpandingTildeInPath] UTF8String]); tr_variantDictAddBool(&settings, TR_KEY_incomplete_dir_enabled, [fDefaults boolForKey: @"UseIncompleteDownloadFolder"]); tr_variantDictAddBool(&settings, TR_KEY_lpd_enabled, [fDefaults boolForKey: @"LocalPeerDiscoveryGlobal"]); - tr_variantDictAddInt(&settings, TR_KEY_message_level, TR_MSG_DBG); + tr_variantDictAddInt(&settings, TR_KEY_message_level, TR_LOG_DEBUG); tr_variantDictAddInt(&settings, TR_KEY_peer_limit_global, [fDefaults integerForKey: @"PeersTotal"]); tr_variantDictAddInt(&settings, TR_KEY_peer_limit_per_torrent, [fDefaults integerForKey: @"PeersTorrent"]); diff --git a/macosx/MessageWindowController.m b/macosx/MessageWindowController.m index 53cf2473a..ad31f8740 100644 --- a/macosx/MessageWindowController.m +++ b/macosx/MessageWindowController.m @@ -27,8 +27,8 @@ #import "NSApplicationAdditions.h" #import "NSMutableArrayAdditions.h" #import "NSStringAdditions.h" +#import #import -#import #define LEVEL_ERROR 0 #define LEVEL_INFO 1 @@ -114,17 +114,17 @@ //select proper level in popup button switch ([[NSUserDefaults standardUserDefaults] integerForKey: @"MessageLevel"]) { - case TR_MSG_ERR: + case TR_LOG_ERROR: [fLevelButton selectItemAtIndex: LEVEL_ERROR]; break; - case TR_MSG_INF: + case TR_LOG_INFO: [fLevelButton selectItemAtIndex: LEVEL_INFO]; break; - case TR_MSG_DBG: + case TR_LOG_DEBUG: [fLevelButton selectItemAtIndex: LEVEL_DEBUG]; break; default: //safety - [[NSUserDefaults standardUserDefaults] setInteger: TR_MSG_ERR forKey: @"MessageLevel"]; + [[NSUserDefaults standardUserDefaults] setInteger: TR_LOG_ERROR forKey: @"MessageLevel"]; [fLevelButton selectItemAtIndex: LEVEL_ERROR]; } @@ -270,11 +270,11 @@ const NSInteger level = [[message objectForKey: @"Level"] integerValue]; switch (level) { - case TR_MSG_ERR: + case TR_LOG_ERROR: return [NSImage imageNamed: @"RedDot"]; - case TR_MSG_INF: + case TR_LOG_INFO: return [NSImage imageNamed: @"YellowDot"]; - case TR_MSG_DBG: + case TR_LOG_DEBUG: return [NSImage imageNamed: @"PurpleDot"]; default: NSAssert1(NO, @"Unknown message log level: %ld", level); @@ -342,13 +342,13 @@ switch ([fLevelButton indexOfSelectedItem]) { case LEVEL_ERROR: - level = TR_MSG_ERR; + level = TR_LOG_ERROR; break; case LEVEL_INFO: - level = TR_MSG_INF; + level = TR_LOG_INFO; break; case LEVEL_DEBUG: - level = TR_MSG_DBG; + level = TR_LOG_DEBUG; break; default: NSAssert1(NO, @"Unknown message log level: %ld", [fLevelButton indexOfSelectedItem]); @@ -535,13 +535,13 @@ const NSInteger level = [[message objectForKey: @"Level"] integerValue]; switch (level) { - case TR_MSG_ERR: + case TR_LOG_ERROR: levelString = NSLocalizedString(@"Error", "Message window -> level"); break; - case TR_MSG_INF: + case TR_LOG_INFO: levelString = NSLocalizedString(@"Info", "Message window -> level"); break; - case TR_MSG_DBG: + case TR_LOG_DEBUG: levelString = NSLocalizedString(@"Debug", "Message window -> level"); break; default: diff --git a/macosx/Torrent.m b/macosx/Torrent.m index 7851f28e5..392bd1c7a 100644 --- a/macosx/Torrent.m +++ b/macosx/Torrent.m @@ -28,6 +28,7 @@ #import "NSStringAdditions.h" #import "TrackerNode.h" +#import "log.h" #import "transmission.h" // required by utils.h #import "utils.h" // tr_new() @@ -98,11 +99,11 @@ void renameCallback(tr_torrent * torrent, const char * oldPathCharString, const NSString * oldPath = [NSString stringWithUTF8String: oldPathCharString]; NSString * path = [oldPath stringByDeletingLastPathComponent]; - NSString * oldName = [oldPath lastPathComponent]; NSString * newName = [NSString stringWithUTF8String: newNameCharString]; if (error == 0) { + NSString * oldName = [oldPath lastPathComponent]; void (^__block updateNodeAndChildrenForRename)(FileListNode *) = ^(FileListNode * node) { [node updateFromOldName: oldName toNewName: newName inPath: path]; @@ -378,7 +379,7 @@ int trashDataFile(const char * filename) { if (fResumeOnWake) { - tr_ninf( fInfo->name, "restarting because of wakeUp" ); + tr_logAddNamedInfo( fInfo->name, "restarting because of wakeUp" ); tr_torrentStart(fHandle); } } @@ -854,7 +855,6 @@ int trashDataFile(const char * filename) - (void) renameFileNode: (FileListNode *) node withName: (NSString *) newName completionHandler: (void (^)(BOOL didRename)) completionHandler { - NSParameterAssert(node != nil); NSParameterAssert([node torrent] == self); NSParameterAssert(newName != nil); NSParameterAssert(![newName isEqualToString: @""]);