Skip to content

Commit

Permalink
refactor(log): use LOG_INFO_F instead of LOG_INFO (2/3)
Browse files Browse the repository at this point in the history
  • Loading branch information
acelyc111 committed Jan 12, 2023
1 parent 8c149a8 commit 1fa5d1d
Show file tree
Hide file tree
Showing 14 changed files with 303 additions and 318 deletions.
12 changes: 6 additions & 6 deletions src/meta/load_balance_policy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,11 @@ generate_balancer_request(const app_mapper &apps,
CHECK(false, "");
}
LOG_INFO_F("generate balancer: {} {} from {} of disk_tag({}) to {}",
pc.pid,
ans,
from,
get_disk_tag(apps, from, pc.pid),
to);
pc.pid,
ans,
from,
get_disk_tag(apps, from, pc.pid),
to);
return std::make_shared<configuration_balancer_request>(std::move(result));
}

Expand Down Expand Up @@ -370,7 +370,7 @@ bool load_balance_policy::execute_balance(
if (!_migration_result->empty()) {
if (balance_in_turn) {
LOG_INFO_F("stop to handle more apps after we found some actions for {}",
app->get_logname());
app->get_logname());
return false;
}
}
Expand Down
156 changes: 74 additions & 82 deletions src/meta/meta_backup_service.cpp

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/meta/meta_backup_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ struct backup_start_time
<< std::setfill('0') << std::to_string(minute);
return ss.str();
}
friend std::ostream &operator<<(std::ostream &os, const backup_start_time &t)
{
return os << t.to_string();
}
// NOTICE: this function will modify hour and minute, if time is invalid, this func will set
// hour = 24, minute = 0
bool parse_from(const std::string &time)
Expand Down
37 changes: 17 additions & 20 deletions src/meta/meta_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,13 @@ bool construct_replica(meta_view view, const gpid &pid, int max_replica_count)
pc.partition_flags = 0;
pc.max_replica_count = max_replica_count;

LOG_INFO("construct for (%d.%d), select %s as primary, ballot(%" PRId64
"), committed_decree(%" PRId64 "), prepare_decree(%" PRId64 ")",
pid.get_app_id(),
pid.get_partition_index(),
server.node.to_string(),
server.ballot,
server.last_committed_decree,
server.last_prepared_decree);
LOG_INFO_F("construct for ({}), select {} as primary, ballot({}), committed_decree({}), "
"prepare_decree({})",
pid,
server.node,
server.ballot,
server.last_committed_decree,
server.last_prepared_decree);

drop_list.pop_back();

Expand All @@ -178,14 +177,13 @@ bool construct_replica(meta_view view, const gpid &pid, int max_replica_count)
break;
// similar to cc.drop_list, pc.last_drop is also a stack structure
pc.last_drops.insert(pc.last_drops.begin(), iter->node);
LOG_INFO("construct for (%d.%d), select %s into last_drops, ballot(%" PRId64
"), committed_decree(%" PRId64 "), prepare_decree(%" PRId64 ")",
pid.get_app_id(),
pid.get_partition_index(),
iter->node.to_string(),
iter->ballot,
iter->last_committed_decree,
iter->last_prepared_decree);
LOG_INFO_F("construct for ({}), select {} into last_drops, ballot({}), "
"committed_decree({}), prepare_decree({})",
pid,
iter->node,
iter->ballot,
iter->last_committed_decree,
iter->last_prepared_decree);
}

cc.prefered_dropped = (int)drop_list.size() - 1;
Expand Down Expand Up @@ -244,10 +242,9 @@ void proposal_actions::track_current_learner(const dsn::rpc_address &node, const
// if we've collected inforamtions for the learner, then it claims it's down
// we will treat the learning process failed
if (current_learner.ballot != invalid_ballot) {
LOG_INFO("%d.%d: a learner's is down to status(%s), perhaps learn failed",
info.pid.get_app_id(),
info.pid.get_partition_index(),
dsn::enum_to_string(info.status));
LOG_INFO_F("{}: a learner's is down to status({}), perhaps learn failed",
info.pid,
dsn::enum_to_string(info.status));
learning_progress_abnormal_detected = true;
} else {
LOG_DEBUG_F(
Expand Down
60 changes: 30 additions & 30 deletions src/meta/meta_server_failure_detector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ void meta_server_failure_detector::acquire_leader_lock()
// lock granted
LPC_META_SERVER_LEADER_LOCK_CALLBACK,
[this, &err](error_code ec, const std::string &owner, uint64_t version) {
LOG_INFO("leader lock granted callback: err(%s), owner(%s), version(%llu)",
ec.to_string(),
owner.c_str(),
version);
LOG_INFO_F("leader lock granted callback: err({}), owner({}), version({})",
ec,
owner,
version);
err = ec;
if (err == dsn::ERR_OK) {
leader_initialize(owner);
Expand Down Expand Up @@ -178,11 +178,11 @@ void meta_server_failure_detector::reset_stability_stat(const rpc_address &node)
if (iter == _stablity.end())
return;
else {
LOG_INFO("old stability stat: node(%s), start_time(%lld), unstable_count(%d), will reset "
"unstable count to 0",
node.to_string(),
iter->second.last_start_time_ms,
iter->second.unstable_restart_count);
LOG_INFO_F("old stability stat: node({}), start_time({}), unstable_count({}), will reset "
"unstable count to 0",
node,
iter->second.last_start_time_ms,
iter->second.unstable_restart_count);
iter->second.unstable_restart_count = 0;
}
}
Expand Down Expand Up @@ -213,28 +213,28 @@ bool meta_server_failure_detector::update_stability_stat(const fd::beacon_msg &b
if (dsn_now_ms() - w.last_start_time_ms >=
_fd_opts->stable_rs_min_running_seconds * 1000 &&
w.unstable_restart_count > 0) {
LOG_INFO("%s has stably run for a while, reset it's unstable count(%d) to 0",
beacon.from_addr.to_string(),
w.unstable_restart_count);
LOG_INFO_F("{} has stably run for a while, reset it's unstable count({}) to 0",
beacon.from_addr,
w.unstable_restart_count);
w.unstable_restart_count = 0;
}
} else if (beacon.start_time > w.last_start_time_ms) {
LOG_INFO("check %s restarted, last_time(%lld), this_time(%lld)",
beacon.from_addr.to_string(),
w.last_start_time_ms,
beacon.start_time);
LOG_INFO_F("check {} restarted, last_time({}), this_time({})",
beacon.from_addr,
w.last_start_time_ms,
beacon.start_time);
if (beacon.start_time - w.last_start_time_ms <
_fd_opts->stable_rs_min_running_seconds * 1000) {
w.unstable_restart_count++;
LOG_WARNING("%s encounter an unstable restart, total_count(%d)",
beacon.from_addr.to_string(),
w.unstable_restart_count);
} else if (w.unstable_restart_count > 0) {
LOG_INFO("%s restart in %lld ms after last restart, may recover ok, reset "
"it's unstable count(%d) to 0",
beacon.from_addr.to_string(),
beacon.start_time - w.last_start_time_ms,
w.unstable_restart_count);
LOG_INFO_F("{} restart in {} ms after last restart, may recover ok, reset "
"it's unstable count({}) to 0",
beacon.from_addr,
beacon.start_time - w.last_start_time_ms,
w.unstable_restart_count);
w.unstable_restart_count = 0;
}

Expand Down Expand Up @@ -270,13 +270,13 @@ void meta_server_failure_detector::on_ping(const fd::beacon_msg &beacon,
failure_detector::on_ping_internal(beacon, ack);
}

LOG_INFO("on_ping, beacon send time[%ld], is_master(%s), from_node(%s), this_node(%s), "
"primary_node(%s)",
ack.time,
ack.is_master ? "true" : "false",
beacon.from_addr.to_string(),
ack.this_node.to_string(),
ack.primary_node.to_string());
LOG_INFO_F("on_ping, beacon send time[{}], is_master({}), from_node({}), this_node({}), "
"primary_node({})",
ack.time,
ack.is_master ? "true" : "false",
beacon.from_addr,
ack.this_node,
ack.primary_node);

reply(ack);
}
Expand All @@ -285,15 +285,15 @@ void meta_server_failure_detector::on_ping(const fd::beacon_msg &beacon,
meta_server_failure_detector::meta_server_failure_detector(rpc_address leader_address,
bool is_myself_leader)
{
LOG_INFO("set %s as leader", leader_address.to_string());
LOG_INFO_F("set {} as leader", leader_address);
_lock_svc = nullptr;
_is_leader.store(is_myself_leader);
}

void meta_server_failure_detector::set_leader_for_test(rpc_address leader_address,
bool is_myself_leader)
{
LOG_INFO("set %s as leader", leader_address.to_string());
LOG_INFO_F("set {} as leader", leader_address);
_is_leader.store(is_myself_leader);
}

Expand Down
17 changes: 8 additions & 9 deletions src/meta/meta_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ error_code meta_service::start()

dreturn_not_ok_logged(err, "start failure_detector failed, err = %s", err.to_string());
LOG_INFO_F("meta service failure detector is successfully started {}",
_meta_opts.enable_white_list ? "with whitelist enabled" : "");
_meta_opts.enable_white_list ? "with whitelist enabled" : "");

// should register rpc handlers before acquiring leader lock, so that this meta service
// can tell others who is the current leader
Expand All @@ -331,7 +331,7 @@ error_code meta_service::start()
_failure_detector->acquire_leader_lock();
CHECK(_failure_detector->get_leader(nullptr), "must be primary at this point");
LOG_INFO_F("{} got the primary lock, start to recover server state from remote storage",
dsn_primary_address());
dsn_primary_address());

// initialize the load balancer
server_load_balancer *balancer = utils::factory_store<server_load_balancer>::create(
Expand Down Expand Up @@ -364,8 +364,8 @@ error_code meta_service::start()
while ((err = _state->initialize_data_structure()) != ERR_OK) {
if (err == ERR_OBJECT_NOT_FOUND && _meta_opts.recover_from_replica_server) {
LOG_INFO_F("can't find apps from remote storage, and "
"[meta_server].recover_from_replica_server = true, "
"administrator should recover this cluster manually later");
"[meta_server].recover_from_replica_server = true, "
"administrator should recover this cluster manually later");
return dsn::ERR_OK;
}
LOG_ERROR("initialize server state from remote storage failed, err = %s, retry ...",
Expand Down Expand Up @@ -702,8 +702,8 @@ void meta_service::on_update_configuration(dsn::message_ex *req)
reply(req, response);

LOG_INFO_F("refuse request {} coz meta function level is {}",
boost::lexical_cast<std::string>(*request),
_meta_function_level_VALUES_TO_NAMES.find(level)->second);
boost::lexical_cast<std::string>(*request),
_meta_function_level_VALUES_TO_NAMES.find(level)->second);
return;
}

Expand Down Expand Up @@ -745,8 +745,7 @@ void meta_service::on_propose_balancer(configuration_balancer_rpc rpc)
}

const configuration_balancer_request &request = rpc.request();
LOG_INFO_F("get proposal balancer request, gpid({})",
request.gpid);
LOG_INFO_F("get proposal balancer request, gpid({})", request.gpid);
_state->on_propose_balancer(request, rpc.response());
}

Expand All @@ -766,7 +765,7 @@ void meta_service::on_start_recovery(configuration_recovery_rpc rpc)
zauto_write_lock l(_meta_lock);
if (_started.load()) {
LOG_INFO_F("service({}) is already started, ignore the recovery request",
dsn_primary_address());
dsn_primary_address());
response.err = ERR_SERVICE_ALREADY_RUNNING;
} else {
_state->on_start_recovery(rpc.request(), response);
Expand Down
8 changes: 4 additions & 4 deletions src/meta/meta_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ bool meta_service::check_status(TRpcHolder rpc, rpc_address *forward_address)
{
if (!_access_controller->allowed(rpc.dsn_request())) {
rpc.response().err = ERR_ACL_DENY;
LOG_INFO("reject request with ERR_ACL_DENY");
LOG_INFO_F("reject request with ERR_ACL_DENY");
return false;
}

Expand All @@ -385,7 +385,7 @@ bool meta_service::check_status(TRpcHolder rpc, rpc_address *forward_address)
} else {
rpc.response().err = ERR_SERVICE_NOT_ACTIVE;
}
LOG_INFO("reject request with %s", rpc.response().err.to_string());
LOG_INFO_F("reject request with {}", rpc.response().err);
return false;
}

Expand All @@ -396,7 +396,7 @@ template <typename TRespType>
bool meta_service::check_status_with_msg(message_ex *req, TRespType &response_struct)
{
if (!_access_controller->allowed(req)) {
LOG_INFO("reject request with ERR_ACL_DENY");
LOG_INFO_F("reject request with ERR_ACL_DENY");
response_struct.err = ERR_ACL_DENY;
reply(req, response_struct);
return false;
Expand All @@ -414,7 +414,7 @@ bool meta_service::check_status_with_msg(message_ex *req, TRespType &response_st
} else {
response_struct.err = ERR_SERVICE_NOT_ACTIVE;
}
LOG_INFO("reject request with %s", response_struct.err.to_string());
LOG_INFO_F("reject request with {}", response_struct.err);
reply(req, response_struct);
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/meta/meta_state_service_zookeeper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ error_code meta_state_service_zookeeper::initialize(const std::vector<std::strin
return ERR_TIMEOUT;
}

LOG_INFO("init meta_state_service_zookeeper succeed");
LOG_INFO_F("init meta_state_service_zookeeper succeed");

// Notice: this reference is released in finalize
add_ref();
Expand Down
Loading

0 comments on commit 1fa5d1d

Please sign in to comment.