mirror of
https://github.com/boostorg/mqtt5.git
synced 2025-07-29 20:17:37 +02:00
Move logger traits out of detail namespace into logger_traits.hpp
Summary: related to T15252, #24 - move logger traits out of detail namespace into logger_traits.hpp to allow writers of their own loggers to verify that their implementation satisfies the LoggerType requirements - move impl/codecs/traits to detail/traits, traits functions are now in detail namespace - logger outputs the contents of props in debug mode Reviewers: ivica Reviewed By: ivica Subscribers: iljazovic, miljen Differential Revision: https://repo.mireo.local/D32524
This commit is contained in:
@ -20,9 +20,9 @@
|
||||
#include <boost/range/algorithm/transform.hpp>
|
||||
|
||||
#include <async_mqtt5/detail/control_packet.hpp>
|
||||
#include <async_mqtt5/detail/traits.hpp>
|
||||
#include <async_mqtt5/impl/codecs/message_decoders.hpp>
|
||||
#include <async_mqtt5/impl/codecs/message_encoders.hpp>
|
||||
#include <async_mqtt5/impl/codecs/traits.hpp>
|
||||
|
||||
namespace async_mqtt5::test {
|
||||
|
||||
@ -89,6 +89,7 @@ template <typename Props>
|
||||
inline std::string to_readable_props(Props props) {
|
||||
std::ostringstream stream;
|
||||
props.visit([&stream](const auto&, const auto& v) -> bool {
|
||||
using namespace async_mqtt5::detail;
|
||||
if constexpr (is_optional<decltype(v)>)
|
||||
if (v.has_value())
|
||||
stream << *v << " ";
|
||||
|
@ -30,7 +30,7 @@ using error_code = boost::system::error_code;
|
||||
template <
|
||||
typename StreamType,
|
||||
typename StreamContext = std::monostate,
|
||||
typename LoggerType = async_mqtt5::detail::noop_logger
|
||||
typename LoggerType = async_mqtt5::noop_logger
|
||||
>
|
||||
class test_autoconnect_stream {
|
||||
public:
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include <async_mqtt5/mqtt_client.hpp>
|
||||
#include <async_mqtt5/types.hpp>
|
||||
#include <async_mqtt5/detail/traits.hpp>
|
||||
|
||||
#include "test_common/message_exchange.hpp"
|
||||
#include "test_common/packet_util.hpp"
|
||||
@ -406,7 +407,7 @@ BOOST_FIXTURE_TEST_CASE(connack_properties, shared_connack_prop_test_data) {
|
||||
connack_props cprops_ = c.connack_properties();
|
||||
cprops_.visit([&](const auto& p, const auto& val) -> bool {
|
||||
BOOST_TEST_REQUIRE(p);
|
||||
if constexpr (is_vector<decltype(val)>)
|
||||
if constexpr (detail::is_vector<decltype(val)>)
|
||||
BOOST_TEST(val == cprops[p]);
|
||||
else {
|
||||
BOOST_TEST_REQUIRE(val.has_value());
|
||||
@ -429,7 +430,7 @@ BOOST_FIXTURE_TEST_CASE(connack_property, shared_connack_prop_test_data) {
|
||||
std::move(broker_side),
|
||||
[&](client_type& c) {
|
||||
cprops.visit([&](const auto& p, const auto& val) -> bool{
|
||||
if constexpr (is_vector<decltype(val)>)
|
||||
if constexpr (detail::is_vector<decltype(val)>)
|
||||
BOOST_TEST(val == c.connack_property(p));
|
||||
else {
|
||||
BOOST_TEST_REQUIRE(val.has_value());
|
||||
|
@ -34,7 +34,11 @@ using strand_type = asio::strand<asio::any_io_executor>;
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(executors)
|
||||
|
||||
void run_test(asio::io_context& ioc, strand_type io_ex, auto bind_async_run, auto bind_async_op) {
|
||||
template <typename AsyncRunOp, typename AsyncOp>
|
||||
void run_test(
|
||||
asio::io_context& ioc, strand_type io_ex,
|
||||
AsyncRunOp&& bind_async_run, AsyncOp&& bind_async_op
|
||||
) {
|
||||
using test::after;
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
|
@ -473,7 +473,7 @@ BOOST_FIXTURE_TEST_CASE(receive_buffer_overflow, shared_test_data) {
|
||||
.async_run(asio::detached);
|
||||
|
||||
asio::steady_timer timer(executor);
|
||||
timer.expires_after(7s);
|
||||
timer.expires_after(10s);
|
||||
timer.async_wait(
|
||||
[&](error_code) {
|
||||
c.async_receive([&](
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include <boost/asio/steady_timer.hpp>
|
||||
#include <boost/asio/ip/tcp.hpp>
|
||||
|
||||
#include <async_mqtt5/logger_traits.hpp>
|
||||
#include <async_mqtt5/types.hpp>
|
||||
#include <async_mqtt5/detail/log_invoke.hpp>
|
||||
#include <async_mqtt5/detail/internal_types.hpp>
|
||||
@ -65,8 +66,8 @@ void run_unit_test(
|
||||
std::move(h)(ec);
|
||||
};
|
||||
|
||||
detail::log_invoke d;
|
||||
detail::connect_op<test::test_stream, detail::noop_logger>(
|
||||
detail::log_invoke<noop_logger> d;
|
||||
detail::connect_op<test::test_stream, noop_logger>(
|
||||
stream, mqtt_ctx, d, std::move(handler)
|
||||
).perform(*std::begin(eps), std::move(ap));
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include <async_mqtt5/mqtt_client.hpp>
|
||||
#include <async_mqtt5/logger.hpp>
|
||||
#include <async_mqtt5/logger_traits.hpp>
|
||||
|
||||
#include "test_common/message_exchange.hpp"
|
||||
#include "test_common/test_service.hpp"
|
||||
@ -54,12 +55,12 @@ void assign_tls_sni(
|
||||
|
||||
|
||||
void logger_test() {
|
||||
BOOST_STATIC_ASSERT(detail::has_at_resolve<logger>);
|
||||
BOOST_STATIC_ASSERT(detail::has_at_tcp_connect<logger>);
|
||||
BOOST_STATIC_ASSERT(detail::has_at_tls_handshake<logger>);
|
||||
BOOST_STATIC_ASSERT(detail::has_at_ws_handshake<logger>);
|
||||
BOOST_STATIC_ASSERT(detail::has_at_connack<logger>);
|
||||
BOOST_STATIC_ASSERT(detail::has_at_disconnect<logger>);
|
||||
BOOST_STATIC_ASSERT(has_at_resolve<logger>);
|
||||
BOOST_STATIC_ASSERT(has_at_tcp_connect<logger>);
|
||||
BOOST_STATIC_ASSERT(has_at_tls_handshake<logger>);
|
||||
BOOST_STATIC_ASSERT(has_at_ws_handshake<logger>);
|
||||
BOOST_STATIC_ASSERT(has_at_connack<logger>);
|
||||
BOOST_STATIC_ASSERT(has_at_disconnect<logger>);
|
||||
}
|
||||
|
||||
using stream_type = boost::beast::websocket::stream<
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <boost/asio/post.hpp>
|
||||
#include <boost/asio/prepend.hpp>
|
||||
|
||||
#include <async_mqtt5/logger_traits.hpp>
|
||||
#include <async_mqtt5/detail/log_invoke.hpp>
|
||||
|
||||
#include <async_mqtt5/impl/client_service.hpp>
|
||||
@ -113,7 +114,7 @@ void run_connect_to_localhost_test(int succeed_after) {
|
||||
);
|
||||
|
||||
auto stream_ctx = stream_context(std::monostate {});
|
||||
auto log = detail::log_invoke();
|
||||
auto log = detail::log_invoke<noop_logger>();
|
||||
auto auto_stream = astream(ioc.get_executor(), stream_ctx, log);
|
||||
auto_stream.brokers("localhost", 1883);
|
||||
|
||||
@ -147,7 +148,7 @@ BOOST_AUTO_TEST_CASE(no_servers) {
|
||||
|
||||
asio::io_context ioc;
|
||||
auto stream_ctx = stream_context(std::monostate{});
|
||||
auto log = detail::log_invoke();
|
||||
auto log = detail::log_invoke<noop_logger>();
|
||||
auto auto_stream = astream(ioc.get_executor(), stream_ctx, log);
|
||||
auto_stream.brokers("", 1883);
|
||||
|
||||
|
@ -692,7 +692,7 @@ BOOST_AUTO_TEST_CASE(test_pingresp) {
|
||||
|
||||
BOOST_AUTO_TEST_CASE(subscription_identifiers) {
|
||||
// check boost::container::small_vector interface
|
||||
BOOST_TEST_REQUIRE(is_small_vector<prop::subscription_identifiers>);
|
||||
BOOST_TEST_REQUIRE(detail::is_small_vector<prop::subscription_identifiers>);
|
||||
|
||||
// check optional interface
|
||||
prop::subscription_identifiers sub_ids;
|
||||
|
Reference in New Issue
Block a user