Skip to content

Commit

Permalink
msg/msg_type: use fmt::format to print entity_addr
Browse files Browse the repository at this point in the history
for better readability

Signed-off-by: Kefu Chai <[email protected]>
  • Loading branch information
tchaikov committed Jun 11, 2022
1 parent 991e56e commit 01f9dc8
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/msg/msg_types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include <string.h>
#include <netdb.h>

#include <fmt/format.h>

#include "common/Formatter.h"

bool entity_name_t::parse(std::string_view s)
Expand Down Expand Up @@ -413,13 +415,9 @@ std::string entity_addr_t::ip_only_to_str() const

std::string entity_addr_t::ip_n_port_to_str() const
{
std::string addr;
addr += ip_only_to_str();
if (is_ipv6()) {
addr = '[' + addr + ']';
return fmt::format("[{}]:{}", ip_only_to_str(), get_port());
} else {
return fmt::format("{}:{}", ip_only_to_str(), get_port());
}
addr += ':';
addr += std::to_string(get_port());
return addr;
}

0 comments on commit 01f9dc8

Please sign in to comment.