Skip to content

Commit

Permalink
Use OC_LOG_IS_ENABLED instead of OC_DEBUG
Browse files Browse the repository at this point in the history
  • Loading branch information
Danielius1922 committed Dec 18, 2023
1 parent 78fbef2 commit fabe5f4
Show file tree
Hide file tree
Showing 26 changed files with 319 additions and 318 deletions.
8 changes: 0 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -334,14 +334,6 @@ if(OC_PKI_ENABLED)
endif()
endif()

if(OC_DEBUG_ENABLED)
list(APPEND PRIVATE_COMPILE_DEFINITIONS "OC_DEBUG")
if(BUILD_MBEDTLS)
list(APPEND MBEDTLS_COMPILE_DEFINITIONS "OC_DEBUG")
endif()
list(APPEND TEST_COMPILE_DEFINITIONS "OC_DEBUG")
endif()

if(OC_CLOUD_ENABLED)
list(APPEND PUBLIC_COMPILE_DEFINITIONS "OC_CLOUD")
set(OC_TCP_ENABLED ON)
Expand Down
4 changes: 2 additions & 2 deletions api/cloud/unittest/cloud_manager_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,13 @@ class TestCloudManagerData : public testing::Test {
static void PrintJson(const oc_rep_t *rep)
{
(void)rep;
#ifdef OC_DEBUG
#if OC_DBG_IS_ENABLED
size_t json_size = oc_rep_to_json(rep, nullptr, 0, true);
std::vector<char> json{};
json.resize(json_size + 1);
oc_rep_to_json(rep, &json[0], json.capacity(), true);
OC_PRINTF("%s", json.data());
#endif /* OC_DEBUG */
#endif /* OC_DBG_IS_ENABLED */
}

oc::oc_rep_unique_ptr GetPayload(const std::string &access_token,
Expand Down
2 changes: 1 addition & 1 deletion api/oc_push.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
#include <inttypes.h>

// TODO: add push component to logs and use standard logging functions
#if defined(OC_PUSHDEBUG) || defined(OC_DEBUG)
#if defined(OC_PUSHDEBUG) || OC_DBG_IS_ENABLED
#define OC_PUSH_DBG(...) OC_LOG(OC_LOG_LEVEL_DEBUG, __VA_ARGS__)
#define OC_PUSH_WRN(...) OC_LOG(OC_LOG_LEVEL_WARNING, __VA_ARGS__)
#define OC_PUSH_ERR(...) OC_LOG(OC_LOG_LEVEL_ERROR, __VA_ARGS__)
Expand Down
4 changes: 2 additions & 2 deletions api/unittest/ocapitest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -687,14 +687,14 @@ class TestServerClient : public testing::Test {
auto *code = static_cast<oc_status_t *>(data->user_data);
memcpy(code, &data->code, sizeof(oc_status_t));

#ifdef OC_DEBUG
#if OC_DBG_IS_ENABLED
if (data->payload != nullptr) {
std::vector<char> json{};
json.resize(256);
oc_rep_to_json(data->payload, &json[0], json.capacity(), true);
OC_PRINTF("%s\n", json.data());
}
#endif /* OC_DEBUG */
#endif /* OC_DBG_IS_ENABLED */

ApiHelper::terminate();
}
Expand Down
4 changes: 2 additions & 2 deletions api/unittest/plgdtimetest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,12 +656,12 @@ addTCPEventCallback(TCPSessionData *tcp_data)
{
auto tcp_events = [](const oc_endpoint_t *endpoint, oc_session_state_t state,
void *data) {
#ifdef OC_DEBUG
#if OC_DBG_IS_ENABLED
oc_string_t ep_str{};
oc_endpoint_to_string(endpoint, &ep_str);
OC_DBG("session event endpoint=%s state=%d", oc_string(ep_str), (int)state);
oc_free_string(&ep_str);
#endif /* OC_DEBUG */
#endif /* OC_DBG_IS_ENABLED */
auto *tsd = static_cast<TCPSessionData *>(data);
if ((oc_endpoint_compare(endpoint, tsd->ep) == 0) &&
(state == OC_SESSION_DISCONNECTED)) {
Expand Down
4 changes: 0 additions & 4 deletions deps/mbedtls-patch.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ set(MBEDTLS_INCLUDE_DIR "${IOTIVITY_SRC_DIR}/deps/mbedtls/include/mbedtls")

if(ENABLE_TESTING OR ENABLE_PROGRAMS)
# configure variables for mbedtls_oc_platform-standalone.in
if(OC_DEBUG_ENABLED)
set(OC_DEBUG_MACRO "#define OC_DEBUG")
endif()

if(OC_LOG_MAXIMUM_LEVEL)
set(OC_LOG_MAXIMUM_LEVEL_MACRO "#define OC_LOG_MAXIMUM_LEVEL (${OC_LOG_MAXIMUM_LEVEL})")
endif()
Expand Down
Loading

0 comments on commit fabe5f4

Please sign in to comment.