From 161cef0746ad1482bdae279c85873765b2b8b529 Mon Sep 17 00:00:00 2001 From: zilai Date: Fri, 29 Sep 2023 05:21:50 -0700 Subject: [PATCH] keep logging module consistent --- src/lib/homestore_backend/hs_homeobject.cpp | 2 +- src/lib/homestore_backend/hs_shard_manager.cpp | 11 +++++------ .../homestore_backend/tests/test_shard_manager.cpp | 8 ++++---- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/lib/homestore_backend/hs_homeobject.cpp b/src/lib/homestore_backend/hs_homeobject.cpp index 08ff9d2f..7a76dfde 100644 --- a/src/lib/homestore_backend/hs_homeobject.cpp +++ b/src/lib/homestore_backend/hs_homeobject.cpp @@ -61,7 +61,7 @@ void HSHomeObject::init_homestore() { }); } - LOGINFO("Initialize and start HomeStore is successfully"); + LOGI("Initialize and start HomeStore is successfully"); } void HSHomeObject::register_homestore_metablk_callback() { diff --git a/src/lib/homestore_backend/hs_shard_manager.cpp b/src/lib/homestore_backend/hs_shard_manager.cpp index f94ff1e9..06f5c1a8 100644 --- a/src/lib/homestore_backend/hs_shard_manager.cpp +++ b/src/lib/homestore_backend/hs_shard_manager.cpp @@ -98,8 +98,8 @@ ShardManager::Result< ShardInfo > HSHomeObject::_create_shard(pg_id_t pg_owner, repl_dev->async_alloc_write(header, sisl::blob{}, value, req); auto info = req->result().get(); if (!bool(info)) { - LOGWARN("create new shard [{}] on pg [{}] is failed with error:{}", new_shard_id & shard_mask, pg_owner, - info.error()); + LOGW("create new shard [{}] on pg [{}] is failed with error:{}", new_shard_id & shard_mask, pg_owner, + info.error()); } return info; } @@ -132,7 +132,7 @@ void HSHomeObject::on_shard_message_commit(int64_t lsn, sisl::blob const& header ReplicationMessageHeader msg_header = *r_cast< const ReplicationMessageHeader* >(header.bytes); repl_dev->async_read(blkids, value, value.size).thenValue([this, lsn, msg_header, blkids, value](auto&& err) { if (err) { - LOGWARNMOD(homeobject, "failed to read data from homestore pba, lsn:{}", lsn); + LOGW(homeobject, "failed to read data from homestore pba, lsn:{}", lsn); } else { sisl::blob value_blob(r_cast< uint8_t* >(value.iovs[0].iov_base), value.size); do_shard_message_commit(lsn, msg_header, blkids, value_blob, nullptr); @@ -152,15 +152,14 @@ void HSHomeObject::do_shard_message_commit(int64_t lsn, ReplicationMessageHeader } if (header.corrupted()) { - LOGWARNMOD(homeobject, "replication message header is corrupted with crc error, lsn:{}", lsn); + LOGW("replication message header is corrupted with crc error, lsn:{}", lsn); if (ctx) { ctx->promise_.setValue(folly::makeUnexpected(ShardError::INVALID_ARG)); } return; } - if (crc32_ieee(init_crc32, value.bytes, value.size) != header.payload_crc) { // header & value is inconsistent; - LOGWARNMOD(homeobject, "replication message header is inconsistent with value, lsn:{}", lsn); + LOGW("replication message header is inconsistent with value, lsn:{}", lsn); if (ctx) { ctx->promise_.setValue(folly::makeUnexpected(ShardError::INVALID_ARG)); } return; } diff --git a/src/lib/homestore_backend/tests/test_shard_manager.cpp b/src/lib/homestore_backend/tests/test_shard_manager.cpp index 51306699..f042dac9 100644 --- a/src/lib/homestore_backend/tests/test_shard_manager.cpp +++ b/src/lib/homestore_backend/tests/test_shard_manager.cpp @@ -183,7 +183,7 @@ TEST_F(ShardManagerTesting, MockSealShard) { auto seal_shard_msg = j.dump(); homeobject::HSHomeObject* ho = dynamic_cast< homeobject::HSHomeObject* >(_home_object.get()); - auto* pg = s_cast(ho->_pg_map[_pg_id].get()); + auto* pg = s_cast< homeobject::HSHomeObject::HS_PG* >(ho->_pg_map[_pg_id].get()); auto repl_dev = pg->repl_dev_; const auto msg_size = sisl::round_up(seal_shard_msg.size(), repl_dev->get_blk_size()); auto req = homeobject::repl_result_ctx< ShardManager::Result< ShardInfo > >::make(msg_size, 512 /*alignment*/); @@ -244,8 +244,8 @@ TEST_F(ShardManagerTestingRecovery, ShardManagerRecovery) { auto app_with_recovery = dp_cast< FixtureAppWithRecovery >(app); const std::string fpath = app_with_recovery->path(); if (std::filesystem::exists(fpath)) { std::filesystem::remove(fpath); } - LOGINFO("creating device files with size {} ", homestore::in_bytes(2 * Gi)); - LOGINFO("creating {} device file", fpath); + LOGI("creating device files with size {} ", homestore::in_bytes(2 * Gi)); + LOGI("creating {} device file", fpath); std::ofstream ofs{fpath, std::ios::binary | std::ios::out | std::ios::trunc}; std::filesystem::resize_file(fpath, 2 * Gi); @@ -282,7 +282,7 @@ TEST_F(ShardManagerTestingRecovery, ShardManagerRecovery) { // release the homeobject and homestore will be shutdown automatically. _home_object.reset(); - LOGINFO("restart home_object"); + LOGI("restart home_object"); // re-create the homeobject and pg infos and shard infos will be recover automatically. _home_object = homeobject::init_homeobject(std::weak_ptr< homeobject::HomeObjectApplication >(app)); ho = dynamic_cast< homeobject::HSHomeObject* >(_home_object.get());