From 9c1aa29334a6b4c66e7edf928b9404173d07dc29 Mon Sep 17 00:00:00 2001 From: Andrey Kashcheev Date: Thu, 18 Dec 2025 13:46:21 +0100 Subject: [PATCH] Add diagnostic output for CURL An optional output path to the verbose logging from CURL Relates-To: DATASDK-84 Signed-off-by: Andrey Kashcheev --- .../core/http/NetworkInitializationSettings.h | 16 +++++++++++++--- olp-cpp-sdk-core/src/http/curl/NetworkCurl.cpp | 14 ++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/olp-cpp-sdk-core/include/olp/core/http/NetworkInitializationSettings.h b/olp-cpp-sdk-core/include/olp/core/http/NetworkInitializationSettings.h index ae1ca4250..d547511ed 100644 --- a/olp-cpp-sdk-core/include/olp/core/http/NetworkInitializationSettings.h +++ b/olp-cpp-sdk-core/include/olp/core/http/NetworkInitializationSettings.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 HERE Europe B.V. + * Copyright (C) 2023-2025 HERE Europe B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,8 +19,9 @@ #pragma once -#include "olp/core/CoreApi.h" -#include "olp/core/http/CertificateSettings.h" +#include +#include +#include namespace olp { namespace http { @@ -38,6 +39,15 @@ struct CORE_API NetworkInitializationSettings { * @brief The custom certificate settings. */ CertificateSettings certificate_settings; + + /** + * @brief The path to the network diagnostic output. + * If not set, diagnostics will not be produced. + * + * @note Currently, only CURL-based network implementation supports this + * setting. + */ + porting::optional diagnostic_output_path = porting::none; }; } // namespace http diff --git a/olp-cpp-sdk-core/src/http/curl/NetworkCurl.cpp b/olp-cpp-sdk-core/src/http/curl/NetworkCurl.cpp index 624585f57..02bf3cf7c 100644 --- a/olp-cpp-sdk-core/src/http/curl/NetworkCurl.cpp +++ b/olp-cpp-sdk-core/src/http/curl/NetworkCurl.cpp @@ -457,6 +457,20 @@ NetworkCurl::NetworkCurl(NetworkInitializationSettings settings) OLP_SDK_LOG_INFO_F( kLogTag, "TLS backend: %s", version_data->ssl_version ? version_data->ssl_version : ""); + + if (settings.diagnostic_output_path) { + stderr_ = fopen(settings.diagnostic_output_path->c_str(), "a"); + if (!stderr_) { + const auto* path_error = strerror(errno); + OLP_SDK_LOG_ERROR_F( + kLogTag, "Failed to open diagnostic output file, error=%s, path=%s", + path_error, settings.diagnostic_output_path->c_str()); + } else { + OLP_SDK_LOG_INFO_F(kLogTag, "Using diagnostic output file, path=%s", + settings.diagnostic_output_path->c_str()); + verbose_ = true; + } + } } NetworkCurl::~NetworkCurl() {