aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/CMMCPConnection.h1
-rw-r--r--Source/CMMCPConnection.m16
2 files changed, 15 insertions, 2 deletions
diff --git a/Source/CMMCPConnection.h b/Source/CMMCPConnection.h
index 6d0b0811..26590d85 100644
--- a/Source/CMMCPConnection.h
+++ b/Source/CMMCPConnection.h
@@ -74,6 +74,7 @@
BOOL retryAllowed;
BOOL delegateResponseToWillQueryString;
+ BOOL consoleLoggingEnabled;
IMP willQueryStringPtr;
diff --git a/Source/CMMCPConnection.m b/Source/CMMCPConnection.m
index 68056ba1..18d89e8b 100644
--- a/Source/CMMCPConnection.m
+++ b/Source/CMMCPConnection.m
@@ -276,6 +276,7 @@ static void forcePingTimeout(int signalNumber);
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willPerformQuery:)
name:@"SMySQLQueryWillBePerformed" object:nil];
+ [[NSUserDefaults standardUserDefaults] addObserver:self forKeyPath:@"ConsoleEnableLogging" options:NSKeyValueObservingOptionNew context:NULL];
return mConnected;
}
@@ -681,6 +682,16 @@ static void forcePingTimeout(int signalNumber);
}
+/**
+ * This method is called as part of Key Value Observing which is used to watch for prefernce changes which effect the interface.
+ */
+- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
+{
+ if ([keyPath isEqualToString:@"ConsoleEnableLogging"]) {
+ consoleLoggingEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:@"ConsoleEnableLogging"];
+ }
+}
+
/*
* Override the standard queryString: method to default to the connection encoding, as before,
* before pssing on to queryString: usingEncoding:.
@@ -726,8 +737,9 @@ static void forcePingTimeout(int signalNumber);
// queryStartTime = clock();
- // Inform the delegate about the query
- if (delegateResponseToWillQueryString)
+ // Inform the delegate about the query if logging is enabled and
+ // delegate responds to willQueryString:
+ if (consoleLoggingEnabled && delegateResponseToWillQueryString)
(void)(NSString*)(*willQueryStringPtr)(delegate, @selector(willQueryString:), query);
// Derive the query string in the correct encoding