<commit_before>#include "endpoint.h"
#include "log/log.h"
#include "common/string_utils.h"

LOG_DECLARE_NAMESPACE("client.endpoint");

namespace Cthun {
namespace Client {

Endpoint::Endpoint(const std::string& ca_crt_path,
                   const std::string& client_crt_path,
                   const std::string& client_key_path)
    : ca_crt_path_ { ca_crt_path },
      client_crt_path_ { client_crt_path },
      client_key_path_ { client_key_path } {
    // Disable websocketpp logging to avoid clashing with ours
    // TODO(ale): it could be useful to stream it to a file

    client_.clear_access_channels(websocketpp::log::alevel::all);
    client_.clear_error_channels(websocketpp::log::elevel::all);

    // Initialize the transport system. Note that in perpetual mode,
    // the event loop does not terminate when there are no connections

    client_.init_asio();
    client_.start_perpetual();

#ifdef CTHUN_CLIENT_SECURE_TRANSPORT
    // Bind the TLS init function
    using websocketpp::lib::bind;
    client_.set_tls_init_handler(bind(&Endpoint::onTlsInit, this, ::_1));
#endif  // CTHUN_CLIENT_SECURE_TRANSPORT

    // Start the event loop thread
    endpoint_thread_.reset(
        new std::thread(&Client_Type::run, &client_));
}

Endpoint::~Endpoint() {
    client_.stop_perpetual();
    closeConnections();
    if (endpoint_thread_ != nullptr && endpoint_thread_->joinable()) {
        endpoint_thread_->join();
    }
}
<commit_msg>(maint) - log websocketpp messages at trace level<commit_after>#include "endpoint.h"
#include "log/log.h"
#include "common/string_utils.h"

LOG_DECLARE_NAMESPACE("client.endpoint");

namespace Cthun {
namespace Client {

Endpoint::Endpoint(const std::string& ca_crt_path,
                   const std::string& client_crt_path,
                   const std::string& client_key_path)
    : ca_crt_path_ { ca_crt_path },
      client_crt_path_ { client_crt_path },
      client_key_path_ { client_key_path } {
    // Disable websocketpp logging if we're not at trace level logging
    if (!LOG_IS_TRACE_ENABLED()) {
        client_.clear_access_channels(websocketpp::log::alevel::all);
        client_.clear_error_channels(websocketpp::log::elevel::all);
    }

    // Initialize the transport system. Note that in perpetual mode,
    // the event loop does not terminate when there are no connections

    client_.init_asio();
    client_.start_perpetual();

#ifdef CTHUN_CLIENT_SECURE_TRANSPORT
    // Bind the TLS init function
    using websocketpp::lib::bind;
    client_.set_tls_init_handler(bind(&Endpoint::onTlsInit, this, ::_1));
#endif  // CTHUN_CLIENT_SECURE_TRANSPORT

    // Start the event loop thread
    endpoint_thread_.reset(
        new std::thread(&Client_Type::run, &client_));
}

Endpoint::~Endpoint() {
    client_.stop_perpetual();
    closeConnections();
    if (endpoint_thread_ != nullptr && endpoint_thread_->joinable()) {
        endpoint_thread_->join();
    }
}

{'fraction_non_alphanumeric': 0.11194029850746269, 'fraction_numerical': 0.0006784260515603799, 'mean_word_length': 3.7873376623376624, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4776935', 'n_tokens_mistral': 935, 'n_tokens_neox': 917, 'n_words': 199}