Skip to content

Commit 15fb2d2

Browse files
committed
application: Move logging macros from .h to .c
Due to incorrect order to libraries during linking stage, which was caused by `coremqtt-config` interface linking to `helpers-logging` build was failing. Therefore, move the logging macros definition from `.h` to `.c`. Signed-off-by: Devaraj Ranganna <[email protected]>
1 parent 86230b0 commit 15fb2d2

File tree

22 files changed

+88
-80
lines changed

22 files changed

+88
-80
lines changed

applications/helpers/ota_orchestrator/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ else()
1818
)
1919

2020
target_link_libraries(ota-update
21+
PUBLIC
2122
jobs-for-aws-iot-embedded-sdk
2223
aws-iot-core-mqtt-file-streams-embedded-c
2324
freertos_kernel
@@ -29,5 +30,7 @@ else()
2930
helpers-events
3031
backoff-algorithm
3132
crt-helpers
33+
PRIVATE
34+
helpers-logging
3235
)
3336
endif()

applications/helpers/ota_orchestrator/src/mqtt_helpers.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@
1414
#include "ota_register_callback.h"
1515
#include "ota_types_definitions.h"
1616

17+
/* Include header that defines log levels. */
18+
#include "logging_levels.h"
19+
20+
/* Configure name and log level for the OTA library. */
21+
#ifndef LIBRARY_LOG_NAME
22+
#define LIBRARY_LOG_NAME "OTA"
23+
#endif
24+
#ifndef LIBRARY_LOG_LEVEL
25+
#define LIBRARY_LOG_LEVEL LOG_INFO
26+
#endif
27+
#include "logging_stack.h"
28+
1729
/* Provides external linkage only when running unit test */
1830
#ifdef UNIT_TESTING
1931
#define STATIC /* as nothing */

applications/helpers/ota_orchestrator/src/ota_orchestrator.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,18 @@
6868
#include "ota_register_callback.h"
6969
#include "ota_types_definitions.h"
7070

71+
/* Include header that defines log levels. */
72+
#include "logging_levels.h"
73+
74+
/* Configure name and log level for the OTA library. */
75+
#ifndef LIBRARY_LOG_NAME
76+
#define LIBRARY_LOG_NAME "OTA"
77+
#endif
78+
#ifndef LIBRARY_LOG_LEVEL
79+
#define LIBRARY_LOG_LEVEL LOG_INFO
80+
#endif
81+
#include "logging_stack.h"
82+
7183
#define NUM_OF_BLOCKS_REQUESTED 1U
7284
#define START_JOB_MSG_LENGTH 147U
7385
#define MAX_JOB_ID_LENGTH 64U

applications/helpers/ota_orchestrator/src/ota_os_freertos.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@
2828

2929
#include "ota_types_definitions.h"
3030

31+
/* Include header that defines log levels. */
32+
#include "logging_levels.h"
33+
34+
/* Configure name and log level for the OTA library. */
35+
#ifndef LIBRARY_LOG_NAME
36+
#define LIBRARY_LOG_NAME "OTA"
37+
#endif
38+
#ifndef LIBRARY_LOG_LEVEL
39+
#define LIBRARY_LOG_LEVEL LOG_INFO
40+
#endif
41+
#include "logging_stack.h"
42+
3143
/* OTA Event queue attributes.*/
3244
#define MAX_MESSAGES 20
3345
#define MAX_MSG_SIZE sizeof( OtaEventMsg_t )

applications/helpers/sntp/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ else()
2020
)
2121

2222
target_link_libraries(helpers-sntp
23+
PUBLIC
2324
backoff-algorithm
2425
connectivity-stack
2526
corepkcs11
2627
coresntp
27-
helpers-logging
2828
mbedtls
29+
PRIVATE
30+
helpers-logging
2931
)
3032
endif()

applications/keyword_detection/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ target_link_libraries(keyword-detection
141141
fri-bsp
142142
helpers-device-advisor
143143
helpers-events
144+
helpers-logging
144145
mbedtls
145146
ota-update
146147
provisioning-lib

applications/keyword_detection/configs/aws_configs/CMakeLists.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ target_include_directories(coremqtt-config
77
.
88
)
99

10-
target_link_libraries(coremqtt-config
11-
INTERFACE
12-
helpers-logging
13-
)
14-
1510
target_compile_definitions(coremqtt-agent-config
1611
INTERFACE
1712
MQTT_AGENT_DO_NOT_USE_CUSTOM_CONFIG

applications/keyword_detection/configs/aws_configs/core_mqtt_config.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,6 @@
2525
#ifndef CORE_MQTT_CONFIG_H
2626
#define CORE_MQTT_CONFIG_H
2727

28-
#include "logging_levels.h"
29-
30-
/* Logging configuration for the MQTT library. */
31-
#ifndef LIBRARY_LOG_NAME
32-
#define LIBRARY_LOG_NAME "MQTT"
33-
#endif
34-
35-
#ifndef LIBRARY_LOG_LEVEL
36-
#define LIBRARY_LOG_LEVEL LOG_INFO
37-
#endif
38-
39-
#include "logging_stack.h"
40-
4128
/**
4229
* @brief The maximum number of MQTT PUBLISH messages that may be pending
4330
* acknowledgment at any time.

applications/keyword_detection/configs/aws_configs/ota_config.h

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,30 +28,6 @@
2828
#ifndef OTA_CONFIG_H_
2929
#define OTA_CONFIG_H_
3030

31-
/**************************************************/
32-
/******* DO NOT CHANGE the following order ********/
33-
/**************************************************/
34-
35-
/* Logging related header files are required to be included in the following order:
36-
* 1. Include the header file "logging_levels.h".
37-
* 2. Define LIBRARY_LOG_NAME and LIBRARY_LOG_LEVEL.
38-
* 3. Include the header file "logging_stack.h".
39-
*/
40-
41-
/* Include header that defines log levels. */
42-
#include "logging_levels.h"
43-
44-
/* Configure name and log level for the OTA library. */
45-
#ifndef LIBRARY_LOG_NAME
46-
#define LIBRARY_LOG_NAME "OTA"
47-
#endif
48-
#ifndef LIBRARY_LOG_LEVEL
49-
#define LIBRARY_LOG_LEVEL LOG_INFO
50-
#endif
51-
#include "logging_stack.h"
52-
53-
/************ End of logging configuration ****************/
54-
5531
/* Include config file used for testing the OTA PAL. This config file defines
5632
* the otapalconfigCODE_SIGNING_CERTIFICATE macro. */
5733
#include "ota_demo_config.h"

applications/keyword_detection/main.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@
3030

3131
#include "FreeRTOSConfig.h"
3232

33+
/* Include header that defines log levels. */
34+
#include "logging_levels.h"
35+
36+
/* Configure name and log level for the OTA library. */
37+
#ifndef LIBRARY_LOG_NAME
38+
#define LIBRARY_LOG_NAME "main"
39+
#endif
40+
#ifndef LIBRARY_LOG_LEVEL
41+
#define LIBRARY_LOG_LEVEL LOG_INFO
42+
#endif
43+
#include "logging_stack.h"
44+
3345
#ifdef AUDIO_VSI
3446
#include "Driver_SAI.h"
3547
#endif

0 commit comments

Comments
 (0)