Skip to content

Commit 9c8d2f3

Browse files
jianminzhaosnej
authored andcommitted
CBL-6960: Consider to restore the logs in destructors
We restored the changes of bbd241d as regard to "Commented out logging calls in Logging destructor overrides" since the logging code has been enhanced significantly and no longer vulnerable to the issue of calling in the destructor.
1 parent f35bcc4 commit 9c8d2f3

File tree

6 files changed

+5
-11
lines changed

6 files changed

+5
-11
lines changed

LiteCore/Database/LiveQuerier.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ namespace litecore {
4949

5050
LiveQuerier::~LiveQuerier() {
5151
if ( _query ) _stop();
52-
//logVerbose("Deleted"); // It is not currently safe to log in a Logging destructor
52+
logVerbose("Deleted");
5353
}
5454

5555
std::string LiveQuerier::loggingIdentifier() const { return string(_expression); }

LiteCore/Database/SequenceTracker.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ namespace litecore {
462462
}
463463

464464
CollectionChangeNotifier::~CollectionChangeNotifier() {
465-
//if ( callback ) logInfo("Deleting"); // It is not currently safe to log in a Logging destructor
465+
if ( callback ) logInfo("Deleting");
466466

467467
if ( tracker ) { tracker->removePlaceholder(_placeholder); }
468468
}

LiteCore/Query/SQLiteQuery.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,7 @@ namespace litecore {
231231
rowCount, recording->data().size, elapsedTime * 1000);
232232
}
233233

234-
~SQLiteQueryEnumerator() override {
235-
//logInfo("Deleted"); // It is not currently safe to log in a Logging destructor
236-
}
234+
~SQLiteQueryEnumerator() override { logInfo("Deleted"); }
237235

238236
int64_t getRowCount() const override {
239237
return _recording->asArray()->count() / 2; // (every other row is a column bitmap)

LiteCore/Storage/DataFile.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,7 @@ namespace litecore {
161161

162162
for ( auto& i : _keyStores ) { i.second->close(); }
163163
_close(forDelete);
164-
if ( _shared->removeDataFile(this) ) {
165-
//logInfo("Closing database"); // It is not currently safe to log in a Logging destructor
166-
}
164+
if ( _shared->removeDataFile(this) ) { logInfo("Closing database"); }
167165
}
168166

169167
void DataFile::reopen() {

Networking/BLIP/BLIPConnection.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ namespace litecore::blip {
162162

163163
protected:
164164
~BLIPIO() override {
165-
#if 0 // It is not currently safe to log in a Logging destructor
166165
double outboxDepth =
167166
(_countOutboxDepth != 0)
168167
? (static_cast<double>(_totalOutboxDepth) / static_cast<double>(_countOutboxDepth))
@@ -173,7 +172,6 @@ namespace litecore::blip {
173172
_countOutboxDepth, _totalBytesWritten, _numRequestsReceived, _totalBytesRead, _timeOpen.elapsed(),
174173
_maxOutboxDepth, outboxDepth);
175174
logStats();
176-
#endif
177175
}
178176

179177
void onWebSocketGotTLSCertificate(slice certData) override {

Replicator/Worker.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ namespace litecore::repl {
109109
: Worker(&parent->connection(), parent, parent->_options, parent->_db, namePrefix, coll) {}
110110

111111
Worker::~Worker() {
112-
//if ( _importance ) logStats(); // It is not currently safe to log in a Logging destructor
112+
if ( _importance ) logStats();
113113
logDebug("destructing (%p); actorName='%s'", this, actorName().c_str());
114114
}
115115

0 commit comments

Comments
 (0)