From b2d168940430f6ab55d0aa635d38bcae1b64fcdb Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Mon, 31 Aug 2009 23:00:39 +0000 Subject: - Re-enable the fine-grained query logging preferences - Add defaults for fine-grained logging preferences - Add a method to TableDocument to allow setting the query mode, and use the query mode to control logging - Set import/export and custom query to set the appropriate query modes --- Interfaces/English.lproj/Preferences.xib | 335 +++++++++++++------------------ Resources/PreferenceDefaults.plist | 8 + Source/CustomQuery.m | 3 + Source/TableDocument.h | 9 + Source/TableDocument.m | 25 ++- Source/TableDump.m | 23 ++- 6 files changed, 207 insertions(+), 196 deletions(-) diff --git a/Interfaces/English.lproj/Preferences.xib b/Interfaces/English.lproj/Preferences.xib index 058441b0..e0fa3133 100644 --- a/Interfaces/English.lproj/Preferences.xib +++ b/Interfaces/English.lproj/Preferences.xib @@ -2,13 +2,12 @@ 1050 - 9L30 + 9L31a 677 949.54 353.00 YES - YES @@ -686,8 +685,8 @@ YES YES - , - . + . + , NO YES NO @@ -733,6 +732,7 @@ 268 {{152, 181}, {123, 18}} + YES 67239424 @@ -755,6 +755,7 @@ 268 {{28, 220}, {120, 17}} + YES 67239488 @@ -771,6 +772,7 @@ 268 {{374, 67}, {38, 17}} + YES 67239488 @@ -787,6 +789,7 @@ 268 {{152, 221}, {106, 18}} + YES -2080244224 @@ -809,6 +812,7 @@ 268 {{152, 66}, {115, 18}} + YES 67239424 @@ -831,6 +835,7 @@ 268 {{152, 201}, {105, 18}} + YES -2080244224 @@ -853,6 +858,7 @@ 268 {{353, 61}, {19, 27}} + YES 917024 @@ -871,6 +877,7 @@ 268 {{273, 64}, {75, 22}} + YES -1804468672 @@ -921,8 +928,8 @@ YES YES - , - . + . + , NO YES NO @@ -939,6 +946,7 @@ 268 {{17, 22}, {131, 17}} + YES 68288064 @@ -955,6 +963,7 @@ 268 {{154, 20}, {75, 22}} + YES -1804468671 @@ -973,6 +982,7 @@ 268 {{152, 141}, {297, 18}} + YES 67239424 @@ -995,6 +1005,7 @@ 268 {{152, 121}, {225, 18}} + YES 67239424 @@ -1017,6 +1028,7 @@ 12 {{154, 167}, {326, 5}} + {0, 0} 67239424 @@ -1039,6 +1051,7 @@ 12 {{154, 92}, {326, 5}} + {0, 0} 67239424 @@ -1061,6 +1074,7 @@ 12 {{154, 53}, {326, 5}} + {0, 0} 67239424 @@ -1083,6 +1097,7 @@ 268 {{152, 101}, {206, 18}} + YES -2080244224 @@ -1103,6 +1118,7 @@ {500, 259} + NSView @@ -2169,15 +2185,16 @@ NSView - + 268 YES 268 - {{152, 81}, {187, 18}} + {{152, 173}, {187, 18}} + YES 67239424 @@ -2198,8 +2215,9 @@ 12 - {{154, 44}, {334, 5}} + {{154, 136}, {334, 5}} + {0, 0} 67239424 @@ -2220,8 +2238,9 @@ 268 - {{152, 58}, {261, 18}} + {{152, 150}, {261, 18}} + YES 67239424 @@ -2242,13 +2261,14 @@ 268 - {{152, 18}, {207, 18}} + {{152, 110}, {207, 18}} + YES 67239424 0 - Enable logging for all queries + Enable logging for queries 1211912703 @@ -2263,9 +2283,10 @@ - -2147483380 - {{180, -5}, {77, 18}} + 268 + {{180, 87}, {77, 18}} + YES 67239424 @@ -2285,9 +2306,10 @@ - -2147483380 - {{180, -28}, {123, 18}} + 268 + {{180, 41}, {123, 18}} + YES 67239424 @@ -2307,9 +2329,10 @@ - -2147483380 - {{180, -51}, {154, 18}} + 268 + {{180, 64}, {154, 18}} + YES 67239424 @@ -2329,9 +2352,10 @@ - -2147483380 - {{180, -74}, {63, 18}} + 268 + {{180, 18}, {63, 18}} + YES 67239424 @@ -2350,7 +2374,9 @@ - {500, 117} + {500, 209} + + NSView @@ -2677,8 +2703,8 @@ AQAAAAA YES YES - , - . + . + , NO YES YES @@ -3443,6 +3469,13 @@ AQAAAAA NSView + + YES + ConsoleEnableInterfaceLogging + ConsoleEnableImportExportLogging + ConsoleEnableCustomQueryLogging + ConsoleEnableErrorLogging + YES @@ -4716,70 +4749,6 @@ AQAAAAA 1160 - - - value: values.EnableInterfaceLogging - - - - - - value: values.EnableInterfaceLogging - value - values.EnableInterfaceLogging - 2 - - - 1162 - - - - value: values.EnableImportExportLogging - - - - - - value: values.EnableImportExportLogging - value - values.EnableImportExportLogging - 2 - - - 1163 - - - - value: values.EnableCustomQueryLogging - - - - - - value: values.EnableCustomQueryLogging - value - values.EnableCustomQueryLogging - 2 - - - 1164 - - - - value: values.EnableErrorLogging - - - - - - value: values.EnableErrorLogging - value - values.EnableErrorLogging - 2 - - - 1165 - selectedIndex: selection.type @@ -5496,6 +5465,70 @@ AQAAAAA 1378 + + + value: values.ConsoleEnableInterfaceLogging + + + + + + value: values.ConsoleEnableInterfaceLogging + value + values.ConsoleEnableInterfaceLogging + 2 + + + 1379 + + + + value: values.ConsoleEnableImportExportLogging + + + + + + value: values.ConsoleEnableImportExportLogging + value + values.ConsoleEnableImportExportLogging + 2 + + + 1380 + + + + value: values.ConsoleEnableCustomQueryLogging + + + + + + value: values.ConsoleEnableCustomQueryLogging + value + values.ConsoleEnableCustomQueryLogging + 2 + + + 1381 + + + + value: values.ConsoleEnableErrorLogging + + + + + + value: values.ConsoleEnableErrorLogging + value + values.ConsoleEnableErrorLogging + 2 + + + 1382 + @@ -8584,7 +8617,7 @@ AQAAAAA com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{447, 564}, {500, 117}} + {{388, 472}, {500, 209}} com.apple.InterfaceBuilder.CocoaPlugin YES @@ -8757,7 +8790,7 @@ AQAAAAA - 1378 + 1382 @@ -8792,122 +8825,34 @@ AQAAAAA NSObject - - toggleCollapse: - id - IBProjectSource - Source/TablesList.h + Source/SPExporter.h - NSWindow + NSObject IBProjectSource - Source/SPWindowAdditions.h + Source/SPQueryFavoriteManager.h - SPPreferenceController - NSWindowController + NSObject - YES - - YES - addFavorite: - changeFont: - displayAutoUpdatePreferences: - displayEditorPreferences: - displayFavoritePreferences: - displayGeneralPreferences: - displayNetworkPreferences: - displayNotificationPreferences: - displayTablePreferences: - duplicateFavorite: - favoriteTypeDidChange: - removeFavorite: - saveFavorite: - setDefaultColors: - showCustomQueryFontPanel: - updateDefaultFavorite: - - - YES - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - - - - YES - - YES - autoUpdateView - defaultFavoritePopup - editorFontName - editorView - favoritesController - favoritesTabView - favoritesTableView - favoritesView - generalView - networkView - notificationsView - preferencesWindow - socketPasswordField - sshPasswordField - sshSQLPasswordField - standardPasswordField - tablesView - - - YES - NSView - NSPopUpButton - NSTextField - NSView - NSArrayController - NSTabView - NSTableView - NSView - NSView - NSView - NSView - NSWindow - NSSecureTextField - NSSecureTextField - NSSecureTextField - NSSecureTextField - NSView - + toggleCollapse: + id IBProjectSource - Source/SPPreferenceController.h + Source/TablesList.h - - - YES - NSObject - - IBDocumentRelativeSource - ../../Frameworks/Sparkle.framework/Versions/A/Headers/SUUpdater.h + NSWindow + + IBProjectSource + Source/SPWindowAdditions.h @@ -8964,7 +8909,6 @@ AQAAAAA editorView favoriteHostTextField favoriteHostTextFieldSSH - favoriteHostTextFieldSocket favoriteNameTextField favoriteUserTextField favoriteUserTextFieldSSH @@ -8995,7 +8939,6 @@ AQAAAAA NSTextField NSTextField NSTextField - NSTextField NSArrayController NSTabView NSTableView @@ -9012,8 +8955,18 @@ AQAAAAA + IBProjectSource + Source/SPPreferenceController.h + + + + + YES + + NSObject + IBDocumentRelativeSource - ../../Source/SPPreferenceController.h + ../../Frameworks/Sparkle.framework/Versions/A/Headers/SUUpdater.h diff --git a/Resources/PreferenceDefaults.plist b/Resources/PreferenceDefaults.plist index bf58e7ec..4f127c88 100644 --- a/Resources/PreferenceDefaults.plist +++ b/Resources/PreferenceDefaults.plist @@ -88,6 +88,14 @@ ConsoleEnableLogging + ConsoleEnableInterfaceLogging + + ConsoleEnableCustomQueryLogging + + ConsoleEnableImportExportLogging + + ConsoleEnableErrorLogging + ConsoleShowTimestamps ConsoleShowSelectsAndShows diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m index 17ca6d35..dcb42c26 100644 --- a/Source/CustomQuery.m +++ b/Source/CustomQuery.m @@ -340,6 +340,7 @@ // BOOL queriesSeparatedByDelimiter = NO; NSCharacterSet *whitespaceAndNewlineSet = [NSCharacterSet whitespaceAndNewlineCharacterSet]; + [tableDocumentInstance setQueryMode:SP_QUERYMODE_CUSTOMQUERY]; // Notify listeners that a query has started [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryWillBePerformed" object:self]; @@ -573,6 +574,8 @@ // Restore automatic query retries [mySQLConnection setAllowQueryRetries:YES]; + + [tableDocumentInstance setQueryMode:SP_QUERYMODE_INTERFACE]; // If no results were returned, redraw the empty table and post notifications before returning. if ( ![fullResult count] ) { diff --git a/Source/TableDocument.h b/Source/TableDocument.h index 3c890a40..0ad2638f 100644 --- a/Source/TableDocument.h +++ b/Source/TableDocument.h @@ -32,6 +32,13 @@ @class SPConnectionController, SPUserManager; +enum sp_current_query_mode +{ + SP_QUERYMODE_INTERFACE = 0, + SP_QUERYMODE_CUSTOMQUERY = 1, + SP_QUERYMODE_IMPORTEXPORT = 2 +}; + /** * The TableDocument class controls the primary database view window. */ @@ -124,6 +131,7 @@ BOOL _shouldOpenConnectionAutomatically; BOOL _isConnected; BOOL _mainNibLoaded; + int _queryMode; NSToolbar *mainToolbar; NSToolbarItem *chooseDatabaseToolbarItem; @@ -180,6 +188,7 @@ - (IBAction)checksumTable:(id)sender; // Other methods +- (void) setQueryMode:(int)theQueryMode; - (NSString *)host; - (IBAction)closeSheet:(id)sender; - (IBAction)closeErrorConnectionSheet:(id)sender; diff --git a/Source/TableDocument.m b/Source/TableDocument.m index ece7d376..84aad499 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -71,6 +71,7 @@ _mainNibLoaded = NO; _encoding = [[NSString alloc] initWithString:@"utf8"]; _isConnected = NO; + _queryMode = SP_QUERYMODE_INTERFACE; chooseDatabaseButton = nil; chooseDatabaseToolbarItem = nil; connectionController = nil; @@ -1051,6 +1052,14 @@ [[SPQueryConsole sharedQueryConsole] clearConsole:sender]; } +/** + * Set a query mode, used to control logging dependant on preferences + */ +- (void) setQueryMode:(int)theQueryMode +{ + _queryMode = theQueryMode; +} + #pragma mark - #pragma mark Encoding Methods @@ -2802,9 +2811,15 @@ * Invoked when the framework is about to perform a query. */ - (void)willQueryString:(NSString *)query connection:(id)connection -{ - if ([[NSUserDefaults standardUserDefaults] boolForKey:@"ConsoleEnableLogging"]) { - [[SPQueryConsole sharedQueryConsole] showMessageInConsole:query]; +{ + NSLog(@"Mode is %i, bool is %@", _queryMode, [prefs boolForKey:@"ConsoleEnableImportExportLogging"]?@"on":@"off"); + if ([prefs boolForKey:@"ConsoleEnableLogging"]) { + if ((_queryMode == SP_QUERYMODE_INTERFACE && [prefs boolForKey:@"ConsoleEnableInterfaceLogging"]) + || (_queryMode == SP_QUERYMODE_CUSTOMQUERY && [prefs boolForKey:@"ConsoleEnableCustomQueryLogging"]) + || (_queryMode == SP_QUERYMODE_IMPORTEXPORT && [prefs boolForKey:@"ConsoleEnableImportExportLogging"])) + { + [[SPQueryConsole sharedQueryConsole] showMessageInConsole:query]; + } } } @@ -2813,7 +2828,9 @@ */ - (void)queryGaveError:(NSString *)error connection:(id)connection { - [[SPQueryConsole sharedQueryConsole] showErrorInConsole:error]; + if ([prefs boolForKey:@"ConsoleEnableLogging"] && [prefs boolForKey:@"ConsoleEnableErrorLogging"]) { + [[SPQueryConsole sharedQueryConsole] showErrorInConsole:error]; + } } /** diff --git a/Source/TableDump.m b/Source/TableDump.m index a41b61df..a9b1be37 100644 --- a/Source/TableDump.m +++ b/Source/TableDump.m @@ -462,6 +462,8 @@ [NSApp beginSheet:singleProgressSheet modalForWindow:tableWindow modalDelegate:self didEndSelector:nil contextInfo:nil]; [singleProgressSheet makeKeyWindow]; + [tableDocumentInstance setQueryMode:SP_QUERYMODE_IMPORTEXPORT]; + // Read in the file in a loop sqlParser = [[SPSQLParser alloc] init]; sqlDataBuffer = [[NSMutableData alloc] init]; @@ -480,6 +482,7 @@ [sqlParser release]; [sqlDataBuffer release]; [importPool drain]; + [tableDocumentInstance setQueryMode:SP_QUERYMODE_INTERFACE]; return; } @@ -526,6 +529,7 @@ [sqlParser release]; [sqlDataBuffer release]; [importPool drain]; + [tableDocumentInstance setQueryMode:SP_QUERYMODE_INTERFACE]; return; } } @@ -601,6 +605,7 @@ [sqlParser release]; [sqlDataBuffer release]; [importPool drain]; + [tableDocumentInstance setQueryMode:SP_QUERYMODE_INTERFACE]; // Close progress sheet [NSApp endSheet:singleProgressSheet]; @@ -657,6 +662,8 @@ didEndSelector:nil contextInfo:nil]; [singleProgressSheet makeKeyWindow]; + + [tableDocumentInstance setQueryMode:SP_QUERYMODE_IMPORTEXPORT]; // Read the file with the current connection encoding. dumpFile = [NSString stringWithContentsOfFile:filename @@ -673,6 +680,7 @@ nil, nil, nil, [errorStr localizedDescription] ); + [tableDocumentInstance setQueryMode:SP_QUERYMODE_INTERFACE]; return; } @@ -705,12 +713,14 @@ NSLocalizedString(@"Could not parse file as CSV", @"Error when we can't parse/split file as CSV") ); [importArray release], importArray = nil; + [tableDocumentInstance setQueryMode:SP_QUERYMODE_INTERFACE]; return; } if (progressCancelled) { progressCancelled = NO; [importArray release], importArray = nil; + [tableDocumentInstance setQueryMode:SP_QUERYMODE_INTERFACE]; return; } MCPResult *theResult; @@ -745,6 +755,7 @@ NSLocalizedString(@"The CSV was read as containing more than 512 columns, more than the maximum columns permitted for speed reasons by Sequel Pro.\n\nThis usually happens due to errors reading the CSV; please double-check the CSV to be imported and the line endings and escape characters at the bottom of the CSV selection dialog.", @"Error when CSV appears to have too many columns to import, probably due to line ending mismatch") ); [importArray release], importArray = nil; + [tableDocumentInstance setQueryMode:SP_QUERYMODE_INTERFACE]; return; } @@ -870,6 +881,8 @@ //free arrays if (fieldMappingArray) [fieldMappingArray release], fieldMappingArray = nil; [importArray release], importArray = nil; + + [tableDocumentInstance setQueryMode:SP_QUERYMODE_INTERFACE]; // Import finished Growl notification [[SPGrowlController sharedGrowlController] notifyWithTitle:@"Import Finished" @@ -999,7 +1012,9 @@ [NSApp beginSheet:singleProgressSheet modalForWindow:tableWindow modalDelegate:self didEndSelector:nil contextInfo:nil]; - + + [tableDocumentInstance setQueryMode:SP_QUERYMODE_IMPORTEXPORT]; + // Copy over the selected table names into a table in preparation for iteration for ( i = 0 ; i < [tables count] ; i++ ) { if ( [NSArrayObjectAtIndex(NSArrayObjectAtIndex(tables, i), 0) boolValue] ) { @@ -1292,6 +1307,8 @@ [errorsSheet orderOut:nil]; } + [tableDocumentInstance setQueryMode:SP_QUERYMODE_INTERFACE]; + [sqlString release]; return TRUE; } @@ -2067,6 +2084,8 @@ [singleProgressText displayIfNeeded]; [singleProgressBar setDoubleValue:0]; [singleProgressBar displayIfNeeded]; + + [tableDocumentInstance setQueryMode:SP_QUERYMODE_IMPORTEXPORT]; // Open the progress sheet [NSApp beginSheet:singleProgressSheet @@ -2223,6 +2242,8 @@ [NSApp endSheet:errorsSheet]; [errorsSheet orderOut:nil]; } + + [tableDocumentInstance setQueryMode:SP_QUERYMODE_INTERFACE]; return TRUE; } -- cgit v1.2.3