aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2009-08-31 23:00:39 +0000
committerrowanbeentje <rowan@beent.je>2009-08-31 23:00:39 +0000
commitb2d168940430f6ab55d0aa635d38bcae1b64fcdb (patch)
tree49f9710ed77113830142d652cc2107f951b6cbc9 /Source
parent934f1d41fa8699b3baba3c4ab7631e136fee14b7 (diff)
downloadsequelpro-b2d168940430f6ab55d0aa635d38bcae1b64fcdb.tar.gz
sequelpro-b2d168940430f6ab55d0aa635d38bcae1b64fcdb.tar.bz2
sequelpro-b2d168940430f6ab55d0aa635d38bcae1b64fcdb.zip
- 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
Diffstat (limited to 'Source')
-rw-r--r--Source/CustomQuery.m3
-rw-r--r--Source/TableDocument.h9
-rw-r--r--Source/TableDocument.m25
-rw-r--r--Source/TableDump.m23
4 files changed, 55 insertions, 5 deletions
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;
}