Skip to content

Commit

Permalink
feat: refine log level
Browse files Browse the repository at this point in the history
  • Loading branch information
shuai132 committed Jun 19, 2024
1 parent fb3ade9 commit df54711
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 17 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ jobs:
run: ./asio_net_test_rpc_reconnect${{ matrix.env.BIN_SUFFIX }}

- name: Test RPC (ssl)
if: matrix.os == 'macos-latest'
working-directory: build
run: ./asio_net_test_rpc_ssl${{ matrix.env.BIN_SUFFIX }}

Expand Down
2 changes: 1 addition & 1 deletion include/asio_net/detail/rpc_session_t.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class rpc_session_t : noncopyable, public std::enable_shared_from_this<rpc_sessi
if (tcp_session) {
tcp_session->send(std::move(data));
} else {
ASIO_NET_LOGW("tcp_session expired on sendPackage");
ASIO_NET_LOGW("tcp_session expired");
}
};

Expand Down
8 changes: 2 additions & 6 deletions include/asio_net/detail/tcp_channel_t.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@ class tcp_channel_t : private noncopyable {
do_close();
return;
} else if (ec || size == 0) {
if (ec != asio::error::operation_aborted) {
ASIO_NET_LOGE("do_read_header: %s, size: %zu", ec.message().c_str(), size);
}
ASIO_NET_LOGD("do_read_header: %s, size: %zu", ec.message().c_str(), size);
do_close();
return;
}
Expand All @@ -122,9 +120,7 @@ class tcp_channel_t : private noncopyable {
do_close();
return;
} else if (ec || size == 0) {
if (ec != asio::error::operation_aborted) {
ASIO_NET_LOGE("do_read_body: %s, size: %zu", ec.message().c_str(), size);
}
ASIO_NET_LOGD("do_read_body: %s, size: %zu", ec.message().c_str(), size);
do_close();
return;
}
Expand Down
12 changes: 6 additions & 6 deletions include/asio_net/detail/tcp_server_t.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ inline void tcp_server_t<socket_type::normal>::do_accept<socket_type::normal>()
session->start();
if (on_session) on_session(session);
tcp_server_t<socket_type::normal>::do_accept<socket_type::normal>();
} else if (ec != asio::error::operation_aborted) {
ASIO_NET_LOGE("do_accept: %s", ec.message().c_str());
} else {
ASIO_NET_LOGD("do_accept: %s", ec.message().c_str());
}
});
}
Expand All @@ -118,8 +118,8 @@ inline void tcp_server_t<socket_type::domain>::do_accept<socket_type::domain>()
session->start();
if (on_session) on_session(session);
tcp_server_t<socket_type::domain>::do_accept<socket_type::domain>();
} else if (ec != asio::error::operation_aborted) {
ASIO_NET_LOGE("do_accept: %s", ec.message().c_str());
} else {
ASIO_NET_LOGD("do_accept: %s", ec.message().c_str());
}
});
}
Expand All @@ -140,8 +140,8 @@ inline void tcp_server_t<socket_type::ssl>::do_accept<socket_type::ssl>() {
}
});
do_accept<socket_type::ssl>();
} else if (ec != asio::error::operation_aborted) {
ASIO_NET_LOGE("do_accept: %s", ec.message().c_str());
} else {
ASIO_NET_LOGD("do_accept: %s", ec.message().c_str());
}
});
}
Expand Down
4 changes: 2 additions & 2 deletions include/asio_net/detail/udp_server_t.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class udp_server_t : private noncopyable {
if (!ec && length > 0) {
if (on_data) on_data((uint8_t*)data_.data(), length, from_endpoint_);
do_receive();
} else if (ec != asio::error::operation_aborted) {
ASIO_NET_LOGE("udp_server error: %s", ec.message().c_str());
} else {
ASIO_NET_LOGD("udp_server error: %s", ec.message().c_str());
}
});
}
Expand Down
4 changes: 2 additions & 2 deletions include/asio_net/server_discovery.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ class receiver {
service_found_handle_(std::move(msgs[1]), std::move(msgs[2]));
}
do_receive();
} else if (ec != asio::error::operation_aborted) {
ASIO_NET_LOGE("server_discovery: receive: err: %s", ec.message().c_str());
} else {
ASIO_NET_LOGD("server_discovery: receive: %s", ec.message().c_str());
}
});
}
Expand Down
2 changes: 2 additions & 0 deletions test/domain_tcp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ int main(int argc, char** argv) {
client.open(ENDPOINT);
client.run();
}).join();

std::this_thread::sleep_for(std::chrono::milliseconds(100));
ASSERT(pass_flag_session_close);
ASSERT(pass_flag_client_close);
return EXIT_SUCCESS;
Expand Down

0 comments on commit df54711

Please sign in to comment.