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 --- Source/TableDocument.m | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'Source/TableDocument.m') 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]; + } } /** -- cgit v1.2.3