diff options
Diffstat (limited to 'Source/CMMCPConnection.m')
-rw-r--r-- | Source/CMMCPConnection.m | 16 |
1 files changed, 14 insertions, 2 deletions
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 |