Skip to content

Commit 8d13756

Browse files
Add diagnostic output for CURL (#1650)
An optional output path to the verbose logging from CURL Relates-To: DATASDK-84 Signed-off-by: Andrey Kashcheev <[email protected]>
1 parent 30491a9 commit 8d13756

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

olp-cpp-sdk-core/include/olp/core/http/NetworkInitializationSettings.h

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2023 HERE Europe B.V.
2+
* Copyright (C) 2023-2025 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,8 +19,9 @@
1919

2020
#pragma once
2121

22-
#include "olp/core/CoreApi.h"
23-
#include "olp/core/http/CertificateSettings.h"
22+
#include <olp/core/CoreApi.h>
23+
#include <olp/core/http/CertificateSettings.h>
24+
#include <olp/core/porting/optional.h>
2425

2526
namespace olp {
2627
namespace http {
@@ -38,6 +39,15 @@ struct CORE_API NetworkInitializationSettings {
3839
* @brief The custom certificate settings.
3940
*/
4041
CertificateSettings certificate_settings;
42+
43+
/**
44+
* @brief The path to the network diagnostic output.
45+
* If not set, diagnostics will not be produced.
46+
*
47+
* @note Currently, only CURL-based network implementation supports this
48+
* setting.
49+
*/
50+
porting::optional<std::string> diagnostic_output_path = porting::none;
4151
};
4252

4353
} // namespace http

olp-cpp-sdk-core/src/http/curl/NetworkCurl.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,20 @@ NetworkCurl::NetworkCurl(NetworkInitializationSettings settings)
457457
OLP_SDK_LOG_INFO_F(
458458
kLogTag, "TLS backend: %s",
459459
version_data->ssl_version ? version_data->ssl_version : "<empty>");
460+
461+
if (settings.diagnostic_output_path) {
462+
stderr_ = fopen(settings.diagnostic_output_path->c_str(), "a");
463+
if (!stderr_) {
464+
const auto* path_error = strerror(errno);
465+
OLP_SDK_LOG_ERROR_F(
466+
kLogTag, "Failed to open diagnostic output file, error=%s, path=%s",
467+
path_error, settings.diagnostic_output_path->c_str());
468+
} else {
469+
OLP_SDK_LOG_INFO_F(kLogTag, "Using diagnostic output file, path=%s",
470+
settings.diagnostic_output_path->c_str());
471+
verbose_ = true;
472+
}
473+
}
460474
}
461475

462476
NetworkCurl::~NetworkCurl() {

0 commit comments

Comments
 (0)