// // Copyright (c) 2023-2025 Ivica Siladic, Bruno Iljazovic, Korina Simicevic // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt) // #ifndef BOOST_MQTT5_LOG_INVOKE_HPP #define BOOST_MQTT5_LOG_INVOKE_HPP #include #include #include #include #include #include #include #include namespace boost::mqtt5::detail { namespace asio = boost::asio; using boost::system::error_code; template class log_invoke { LoggerType _logger; public: explicit log_invoke(LoggerType logger = {}) : _logger(std::move(logger)) {} void at_resolve( error_code ec, std::string_view host, std::string_view port, const asio::ip::tcp::resolver::results_type& eps ) { if constexpr (has_at_resolve) _logger.at_resolve(ec, host, port, eps); } void at_tcp_connect(error_code ec, asio::ip::tcp::endpoint ep) { if constexpr (has_at_tcp_connect) _logger.at_tcp_connect(ec, ep); } void at_tls_handshake(error_code ec, asio::ip::tcp::endpoint ep) { if constexpr (has_at_tls_handshake) _logger.at_tls_handshake(ec, ep); } void at_ws_handshake(error_code ec, asio::ip::tcp::endpoint ep) { if constexpr (has_at_ws_handshake) _logger.at_ws_handshake(ec, ep); } void at_connack( reason_code rc, bool session_present, const connack_props& ca_props ) { if constexpr (has_at_connack) _logger.at_connack(rc, session_present, ca_props); } void at_disconnect(reason_code rc, const disconnect_props& dc_props) { if constexpr (has_at_disconnect) _logger.at_disconnect(rc, dc_props); } void at_transport_error(error_code ec) { if constexpr (has_at_transport_error) _logger.at_transport_error(ec); } }; } // end namespace boost::mqtt5::detail #endif // !BOOST_MQTT5_LOG_INVOKE_HPP