Skip to content

Commit

Permalink
refactor log messages into client constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
cwaldren-ld committed May 28, 2024
1 parent 8ce63b2 commit bf808b9
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 18 deletions.
10 changes: 10 additions & 0 deletions libs/client-sdk/src/client_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,16 @@ ClientImpl::ClientImpl(Config in_cfg,
eval_reasons_available_(config_.DataSourceConfig().with_reasons) {
flag_manager_.LoadCache(context_);

if (auto custom_ca = http_properties_.Tls().CustomCAFile()) {
LD_LOG(logger_, LogLevel::kInfo)
<< "TLS peer verification configured with custom CA file: "
<< *custom_ca;
}
if (http_properties_.Tls().PeerVerifyMode() ==
config::shared::built::TlsOptions::VerifyMode::kVerifyNone) {
LD_LOG(logger_, LogLevel::kInfo) << "TLS peer verification disabled";
}

if (config_.Events().Enabled() && !config_.Offline()) {
event_processor_ =
std::make_unique<events::AsioEventProcessor<ClientSDK>>(
Expand Down
9 changes: 0 additions & 9 deletions libs/client-sdk/src/data_sources/polling_data_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,6 @@ PollingDataSource::PollingDataSource(
auto const& polling_config = std::get<
config::shared::built::PollingConfig<config::shared::ClientSDK>>(
data_source_config.method);
if (http_properties.Tls().CustomCAFile()) {
LD_LOG(logger_, LogLevel::kDebug)
<< "TLS peer verification configured with custom CA file: "
<< *http_properties.Tls().CustomCAFile();
}
if (http_properties.Tls().PeerVerifyMode() ==
config::shared::built::TlsOptions::VerifyMode::kVerifyNone) {
LD_LOG(logger_, LogLevel::kDebug) << "TLS peer verification disabled";
}
if (polling_interval_ < polling_config.min_polling_interval) {
LD_LOG(logger_, LogLevel::kWarn)
<< "Polling interval too frequent, defaulting to "
Expand Down
12 changes: 12 additions & 0 deletions libs/server-sdk/src/client_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "data_interfaces/system/idata_system.hpp"

#include <launchdarkly/config/shared/built/http_properties.hpp>
#include <launchdarkly/encoding/sha_256.hpp>
#include <launchdarkly/events/asio_event_processor.hpp>
#include <launchdarkly/events/data/common_events.hpp>
Expand Down Expand Up @@ -124,6 +125,17 @@ ClientImpl::ClientImpl(Config config, std::string const& version)
EventFactory::WithReasons()) {
LD_LOG(logger_, LogLevel::kDebug)
<< "data system: " << data_system_->Identity();
if (auto custom_ca = http_properties_.Tls().CustomCAFile()) {
LD_LOG(logger_, LogLevel::kInfo)
<< "TLS peer verification configured with custom CA file: "
<< *custom_ca;
}
if (http_properties_.Tls().PeerVerifyMode() ==
launchdarkly::config::shared::built::TlsOptions::VerifyMode::
kVerifyNone) {
LD_LOG(logger_, LogLevel::kInfo) << "TLS peer verification disabled";
}

run_thread_ = std::move(std::thread([&]() { ioc_.run(); }));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@ PollingDataSource::PollingDataSource(
request_(MakeRequest(data_source_config, endpoints, http_properties)),
timer_(ioc),
sink_(nullptr) {
if (http_properties.Tls().PeerVerifyMode() ==
launchdarkly::config::shared::built::TlsOptions::VerifyMode::
kVerifyNone) {
LD_LOG(logger_, LogLevel::kDebug) << "TLS peer verification disabled";
}
if (polling_interval_ < data_source_config.min_polling_interval) {
LD_LOG(logger_, LogLevel::kWarn)
<< "Polling interval too frequent, defaulting to "
Expand Down
4 changes: 0 additions & 4 deletions libs/server-sent-events/src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -629,14 +629,10 @@ std::shared_ptr<Client> Builder::build() {
if (custom_ca_file_) {
assert(!custom_ca_file_->empty());
ssl->load_verify_file(*custom_ca_file_);
logging_cb_(
"TLS peer verification configured with custom CA file: " +
*custom_ca_file_);
}

if (skip_verify_peer_) {
ssl->set_verify_mode(ssl::context::verify_none);
logging_cb_("TLS peer verification disabled");
}
}

Expand Down

0 comments on commit bf808b9

Please sign in to comment.