Skip to content

Commit fee368b

Browse files
jkedgarfacebook-github-bot
authored andcommitted
Fix logging for old connection path
Summary: The change over from Olddb to SyncMysqlClient logging (D25504654) was incomplete. The FbSyncMysqlClient used in the new connection path was correctly updated to have a logger, but the SyncMysqlClient used in the old connection path was not. This meant that when the old connection path was being used no log entries were ever sent to Scuba. In addition, the code to turn off Olddb logging was missing a check. All query logging should go through the SyncMysqlClient version but for the old connection path we should still do the olddb logging while the new connection path should use [Fb]SyncMysqlClient logging. Added a new test to validate that there was an existing logger and to also verify that the logging calls get called correctly. This involved moving some test functions up to the MysqlClientBase class. Reviewed By: davidgoode Differential Revision: D28206423 fbshipit-source-id: 6819cff08fd29659ce9a488c57d29a544a5ec7dc
1 parent 275711e commit fee368b

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

squangle/mysql_client/AsyncMysqlClient.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -163,16 +163,6 @@ AsyncMysqlClient::~AsyncMysqlClient() {
163163
VLOG(2) << "AsyncMysqlClient finished destructor";
164164
}
165165

166-
void AsyncMysqlClient::setDBLoggerForTesting(
167-
std::unique_ptr<db::SquangleLoggerBase> dbLogger) {
168-
db_logger_ = std::move(dbLogger);
169-
}
170-
171-
void AsyncMysqlClient::setDBCounterForTesting(
172-
std::unique_ptr<db::DBCounterBase> dbCounter) {
173-
client_stats_ = std::move(dbCounter);
174-
}
175-
176166
void MysqlClientBase::logQuerySuccess(
177167
const db::QueryLoggingData& logging_data,
178168
const Connection& conn) {

squangle/mysql_client/AsyncMysqlClient.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,18 @@ class MysqlClientBase {
170170
return db_logger_.get();
171171
}
172172

173+
// For internal (testing) use only
174+
std::unique_ptr<db::SquangleLoggerBase> setDBLoggerForTesting(
175+
std::unique_ptr<db::SquangleLoggerBase> dbLogger) {
176+
std::swap(db_logger_, dbLogger);
177+
return dbLogger;
178+
}
179+
std::unique_ptr<db::DBCounterBase> setDBCounterForTesting(
180+
std::unique_ptr<db::DBCounterBase> dbCounter) {
181+
std::swap(client_stats_, dbCounter);
182+
return dbCounter;
183+
}
184+
173185
void setConnectionCallback(ObserverCallback connection_cb) {
174186
if (connection_cb_) {
175187
auto old_cb = connection_cb_;
@@ -294,10 +306,6 @@ class AsyncMysqlClient : public MysqlClientBase {
294306
return thread_.get_id();
295307
}
296308

297-
// For internal use only
298-
void setDBLoggerForTesting(std::unique_ptr<db::SquangleLoggerBase> dbLogger);
299-
void setDBCounterForTesting(std::unique_ptr<db::DBCounterBase> dbCounter);
300-
301309
void setPoolsConnectionLimit(uint64_t limit) {
302310
pools_conn_limit_.store(limit, std::memory_order_relaxed);
303311
}

0 commit comments

Comments
 (0)