Skip to content

Commit 916881b

Browse files
committed
Restore util::NullLogger rather than duplicating it each place it's used
1 parent 08546b7 commit 916881b

File tree

4 files changed

+9
-20
lines changed

4 files changed

+9
-20
lines changed

src/realm/util/logger.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,12 @@ class LocalThresholdLogger : public Logger {
497497
std::shared_ptr<Logger> m_chained_logger;
498498
};
499499

500+
/// A logger that performs a noop when logging functions are called
501+
class NullLogger : public Logger {
502+
// Since we don't want to log anything, do_log() does nothing
503+
void do_log(const LogCategory&, Level, const std::string&) override {}
504+
};
505+
500506

501507
// Implementation
502508

test/object-store/audit.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,11 @@ using namespace std::string_literals;
5252
using Catch::Matchers::StartsWith;
5353
using nlohmann::json;
5454

55-
namespace {
56-
class NullLogger : public util::Logger {
57-
// Since we don't want to log anything, do_log() does nothing
58-
void do_log(const util::LogCategory&, Level, const std::string&) override {}
59-
};
60-
} // namespace
61-
6255
static auto audit_logger =
6356
#ifdef AUDIT_LOG_LEVEL
6457
std::make_shared<util::StderrLogger>(AUDIT_LOG_LEVEL);
6558
#else
66-
std::make_shared<NullLogger>();
59+
std::make_shared<util::NullLogger>();
6760
#endif
6861

6962
namespace {

test/object-store/benchmarks/client_reset.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,7 @@ struct BenchmarkLocalClientReset : public reset_utils::TestClientReset {
139139
Transaction& wt_local = (Transaction&)m_local->read_group();
140140
VersionID current_local_version = wt_local.get_version_of_current_transaction();
141141

142-
class NullLogger : public util::Logger {
143-
// Since we don't want to log anything, do_log() does nothing
144-
void do_log(const util::LogCategory&, Level, const std::string&) override {}
145-
} logger;
142+
util::NullLogger logger;
146143

147144
if (m_mode == ClientResyncMode::Recover) {
148145
auto history_local = dynamic_cast<sync::ClientHistory*>(wt_local.get_replication()->_get_history_write());

test/test_client_reset.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,13 +1477,6 @@ TEST(ClientReset_Recover_RecoverableChangesOnListsAfterUnrecoverableAreNotDuplic
14771477
CHECK_EQUAL(changes.size(), 1);
14781478
}
14791479

1480-
namespace {
1481-
class NullLogger : public util::Logger {
1482-
// Since we don't want to log anything, do_log() does nothing
1483-
void do_log(const util::LogCategory&, Level, const std::string&) override {}
1484-
};
1485-
} // namespace
1486-
14871480
// Apply uploaded changes in src to dst as if they had been exchanged by sync
14881481
void apply_changes(DB& src, DB& dst)
14891482
{
@@ -1515,7 +1508,7 @@ void apply_changes(DB& src, DB& dst)
15151508
dst_progress.download.server_version += remote_changesets.size();
15161509
dst_progress.latest_server_version.version += remote_changesets.size();
15171510

1518-
NullLogger logger;
1511+
util::NullLogger logger;
15191512
VersionInfo new_version;
15201513
dst_history.integrate_server_changesets(dst_progress, nullptr, remote_changesets, new_version,
15211514
DownloadBatchState::SteadyState, logger, dst.start_read());

0 commit comments

Comments
 (0)