diff --git a/CMakeLists.txt b/CMakeLists.txt index a1c05fe939107a5916c2a6608a8c7882313b957f..28d5f327cd3185c8c338f37416e251ba95d29024 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -200,7 +200,6 @@ foreach(use_case ${USE_CASES}) "ACTIVATION_BUF_SZ=${${use_case}_ACTIVATION_BUF_SZ}") target_link_libraries(${UC_LIB_NAME} PUBLIC - log arm_math hal profiler diff --git a/MlekModule.cmake b/MlekModule.cmake index 37f08438f522c0c2775cb9074d35026e74ba681b..370a47e3f76fbb2d527d731a6ff0bd0fed868886 100644 --- a/MlekModule.cmake +++ b/MlekModule.cmake @@ -1,5 +1,5 @@ #---------------------------------------------------------------------------- -# SPDX-FileCopyrightText: Copyright 2024 Arm Limited and/or its +# SPDX-FileCopyrightText: Copyright 2024-2025 Arm Limited and/or its # affiliates # SPDX-License-Identifier: Apache-2.0 # @@ -68,7 +68,7 @@ set_platform_global_defaults() message(STATUS "Using CMAKE_TOOLCHAIN_FILE: ${CMAKE_TOOLCHAIN_FILE}") # Make sure the following options are defined before proceeding. -assert_defined(LOG_LEVEL) +assert_defined(MLEK_LOG_LEVEL) assert_defined(TARGET_PLATFORM) assert_defined(USE_CASE_BUILD) assert_defined(CPU_PROFILE_ENABLED) diff --git a/docs/sections/building.md b/docs/sections/building.md index 4025d49d3ea3a6ef28ce66ac5c45e787430e7313..57e6dd293d036af3dbf94b870332e87c23111565 100644 --- a/docs/sections/building.md +++ b/docs/sections/building.md @@ -270,9 +270,13 @@ The build parameters are: set to false, but can be turned on for FPGA targets. The FVP and the CPU core cycle counts are **not** meaningful and are not to be used. -- `LOG_LEVEL`: Sets the verbosity level for the output of the application over `UART`, or `stdout`. Valid values are: - `LOG_LEVEL_TRACE`, `LOG_LEVEL_DEBUG`, `LOG_LEVEL_INFO`, `LOG_LEVEL_WARN`, and `LOG_LEVEL_ERROR`. The default is set - to: `LOG_LEVEL_INFO`. +- `MLEK_LOG_ENABLE`: Enables/disables logging for the whole application. Default is set to `ON`, but if this + project is wrapped as a dependency, the definitions provided by logging interface could be overridden or disabled + altogether. + +- `MLEK_LOG_LEVEL`: Sets the verbosity level for the output of the application over `UART`, or `stdout`. Valid values + are: `MLEK_LOG_LEVEL_TRACE`, `MLEK_LOG_LEVEL_DEBUG`, `MLEK_LOG_LEVEL_INFO`, `MLEK_LOG_LEVEL_WARN`, and + `MLEK_LOG_LEVEL_ERROR`. The default is set to: `MLEK_LOG_LEVEL_INFO`. - `_MODEL_PATH`: The path to the model file that is processed and is included into the application `axf` file. The default value points to one of the delivered set of models. Make sure that the model chosen is aligned diff --git a/docs/sections/customizing.md b/docs/sections/customizing.md index 1d95993b4a0ee841107589a9cec46ba7170ff0c5..2fa24641a4ee06bec5d9c234231bc7ca64bd9b4d 100644 --- a/docs/sections/customizing.md +++ b/docs/sections/customizing.md @@ -535,7 +535,7 @@ However, for clarity, here is the full list of available functions: - `warn` - printf wrapper for warning messages. - `printf_err` - printf wrapper for error messages. -`printf` wrappers can be switched off with `LOG_LEVEL` define: +`printf` wrappers can be switched off with `MLEK_LOG_LEVEL` define: `trace (0) < debug (1) < info (2) < warn (3) < error (4)`. diff --git a/scripts/cmake/cmsis-pack-gen/CMakeLists.txt b/scripts/cmake/cmsis-pack-gen/CMakeLists.txt index 174089fc0e7ab556906eb1ab2841499a9f28ca04..58d691667d55720a854a5350406c23e709d74111 100644 --- a/scripts/cmake/cmsis-pack-gen/CMakeLists.txt +++ b/scripts/cmake/cmsis-pack-gen/CMakeLists.txt @@ -1,5 +1,6 @@ #---------------------------------------------------------------------------- -# SPDX-FileCopyrightText: Copyright 2022 Arm Limited and/or its affiliates +# SPDX-FileCopyrightText: Copyright 2022, 2025 Arm Limited and/or +# its affiliates # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -39,7 +40,7 @@ if (NOT TARGET arm_math) add_subdirectory(${ARM_MATH_PROJECT_DIR} ${CMAKE_BINARY_DIR}/math) endif() -if (NOT TARGET log) +if (NOT TARGET mlek_log) add_subdirectory(${LOGGING_PROJECT_DIR} ${CMAKE_BINARY_DIR}/log) endif() diff --git a/scripts/cmake/configuration_options/common_opts.cmake b/scripts/cmake/configuration_options/common_opts.cmake index d4157d681cffd39f6b3ba3fb93569ec7cb5a5c16..149f171775d682afe2297e86c8663e02ef62d7d1 100644 --- a/scripts/cmake/configuration_options/common_opts.cmake +++ b/scripts/cmake/configuration_options/common_opts.cmake @@ -1,6 +1,6 @@ #---------------------------------------------------------------------------- -# SPDX-FileCopyrightText: Copyright 2021-2022, 2024 Arm Limited and/or its -# affiliates +# SPDX-FileCopyrightText: Copyright 2021-2022, 2024-2025 Arm Limited and/or +# its affiliates # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -27,16 +27,13 @@ message(STATUS "Assessing common user options...") include(util_functions) -USER_OPTION(LOG_LEVEL "Log level for the application" - LOG_LEVEL_INFO - STRING) +USER_OPTION(MLEK_LOG_ENABLE "Enable MLEK logging functions." + ON + BOOL) -set_property(CACHE LOG_LEVEL PROPERTY STRINGS - LOG_LEVEL_TRACE - LOG_LEVEL_DEBUG - LOG_LEVEL_INFO - LOG_LEVEL_WARN - LOG_LEVEL_ERROR) +USER_OPTION(MLEK_LOG_LEVEL "Log level for the application" + MLEK_LOG_LEVEL_INFO + STRING) USER_OPTION(ML_FRAMEWORK "Select the ML inference framework to be used." "TensorFlowLiteMicro" diff --git a/scripts/cmake/configuration_options/options-preset.json b/scripts/cmake/configuration_options/options-preset.json index 57b7a7d78dccc0ca4342dc82eeba350947e96a71..e6401cdb53bf2880929334a7ac3d981e6969a387 100644 --- a/scripts/cmake/configuration_options/options-preset.json +++ b/scripts/cmake/configuration_options/options-preset.json @@ -10,9 +10,9 @@ "name": "log-trace", "hidden": true, "cacheVariables": { - "LOG_LEVEL": { + "MLEK_LOG_LEVEL": { "type": "STRING", - "value": "LOG_LEVEL_TRACE" + "value": "MLEK_LOG_LEVEL_TRACE" } } }, @@ -20,9 +20,9 @@ "name": "log-debug", "hidden": true, "cacheVariables": { - "LOG_LEVEL": { + "MLEK_LOG_LEVEL": { "type": "STRING", - "value": "LOG_LEVEL_DEBUG" + "value": "MLEK_LOG_LEVEL_DEBUG" } } }, @@ -30,9 +30,9 @@ "name": "log-info", "hidden": true, "cacheVariables": { - "LOG_LEVEL": { + "MLEK_LOG_LEVEL": { "type": "STRING", - "value": "LOG_LEVEL_INFO" + "value": "MLEK_LOG_LEVEL_INFO" } } }, @@ -40,9 +40,9 @@ "name": "log-warning", "hidden": true, "cacheVariables": { - "LOG_LEVEL": { + "MLEK_LOG_LEVEL": { "type": "STRING", - "value": "LOG_LEVEL_WARN" + "value": "MLEK_LOG_LEVEL_WARN" } } }, @@ -50,9 +50,9 @@ "name": "log-error", "hidden": true, "cacheVariables": { - "LOG_LEVEL": { + "MLEK_LOG_LEVEL": { "type": "STRING", - "value": "LOG_LEVEL_ERROR" + "value": "MLEK_LOG_LEVEL_ERROR" } } }, @@ -68,4 +68,4 @@ } } ] -} \ No newline at end of file +} diff --git a/scripts/cmake/executorch.cmake b/scripts/cmake/executorch.cmake index 23fd33630af0b8110744f45bd762d3b2792366cf..da8304e2a602e4bbdeb7d1923bddf3b8841a4646 100644 --- a/scripts/cmake/executorch.cmake +++ b/scripts/cmake/executorch.cmake @@ -62,10 +62,10 @@ endif() set(EXECUTORCH_PAL_DEFAULT minimal) # Map ExecuTorch supported log levels -if (${LOG_LEVEL} STREQUAL LOG_LEVEL_TRACE OR - ${LOG_LEVEL} STREQUAL LOG_LEVEL_DEBUG) +if (${LOG_LEVEL} STREQUAL MLEK_LOG_LEVEL_TRACE OR + ${LOG_LEVEL} STREQUAL MLEK_LOG_LEVEL_DEBUG) set(EXECUTORCH_LOG_LEVEL "Debug") -elseif(${LOG_LEVEL} STREQUAL LOG_LEVEL_INFO) +elseif(${LOG_LEVEL} STREQUAL MLEK_LOG_LEVEL_INFO) set(EXECUTORCH_LOG_LEVEL "Info") else() set(EXECUTORCH_LOG_LEVEL "Error") diff --git a/source/application/api/common/CMakeLists.txt b/source/application/api/common/CMakeLists.txt index 52b4010c4309ef20dc294231090fdb3c22cb9f4e..2183822f865cd1a65aa979041b7cfc39633cde5f 100644 --- a/source/application/api/common/CMakeLists.txt +++ b/source/application/api/common/CMakeLists.txt @@ -46,7 +46,7 @@ target_sources(${COMMON_UC_UTILS_TARGET} PRIVATE # Link time library targets: target_link_libraries(${COMMON_UC_UTILS_TARGET} PUBLIC - log # Logging functions + mlek_log # Logging interface arm_math # Math functions ml-framework-iface) # ML framework interface diff --git a/source/application/api/fwk/executorch/CMakeLists.txt b/source/application/api/fwk/executorch/CMakeLists.txt index d49a353ac6e56dafe767ca66abbd24fc2ea15170..eb8b626ecd79faa26c24a8632fdf8b08bbf62480 100644 --- a/source/application/api/fwk/executorch/CMakeLists.txt +++ b/source/application/api/fwk/executorch/CMakeLists.txt @@ -47,7 +47,7 @@ target_include_directories(${ML_FWK_ET_TARGET} PUBLIC # Link time library targets: target_link_libraries(${ML_FWK_ET_TARGET} PUBLIC - log # Logging functions + mlek_log # Logging functions ml-framework-iface # ML framework interface lib ${MLEK_EXECUTORCH_LINK_STR}) # ExecuTorch libraries diff --git a/source/application/api/fwk/tflm/CMakeLists.txt b/source/application/api/fwk/tflm/CMakeLists.txt index 40f7e8c87958d168e71ab8d6a9e01047a22256ff..8eba9cd0ff30e57ac6f13c8356da7e1b6e18812d 100644 --- a/source/application/api/fwk/tflm/CMakeLists.txt +++ b/source/application/api/fwk/tflm/CMakeLists.txt @@ -57,7 +57,7 @@ target_include_directories(${ML_FWK_TFLM_TARGET} PUBLIC # Link time library targets: target_link_libraries(${ML_FWK_TFLM_TARGET} PUBLIC - log # Logging functions + mlek_log # Logging functions ml-framework-iface # ML framework interface tensorflow-lite-micro) # TensorFlow Lite Micro library diff --git a/source/hal/CMakeLists.txt b/source/hal/CMakeLists.txt index 9079550712da13a2a46f67f32b17950b023b68a1..220dbeb7da5e95e09c5f31e5dda9ae4ddd2e13a0 100644 --- a/source/hal/CMakeLists.txt +++ b/source/hal/CMakeLists.txt @@ -57,7 +57,7 @@ add_subdirectory(${PLATFORM_DRIVERS_DIR} ${CMAKE_BINARY_DIR}/platform_driver) # Link time library targets: target_link_libraries(${HAL_TARGET} PUBLIC - log # Logging functions + mlek_log # Logging functions lcd_iface # LCD interface platform_drivers # Platform drivers implementing the required interfaces ) diff --git a/source/hal/source/components/audio/CMakeLists.txt b/source/hal/source/components/audio/CMakeLists.txt index b664c45e57d4637cae0ca9c2ff7d16854ed724fd..dd7950d8962933a405d3f7a5fbc14e718e380605 100644 --- a/source/hal/source/components/audio/CMakeLists.txt +++ b/source/hal/source/components/audio/CMakeLists.txt @@ -1,5 +1,5 @@ #---------------------------------------------------------------------------- -# SPDX-FileCopyrightText: Copyright 2024 Arm Limited and/or +# SPDX-FileCopyrightText: Copyright 2024-2025 Arm Limited and/or # its affiliates # SPDX-License-Identifier: Apache-2.0 # @@ -34,7 +34,7 @@ target_sources(hal_audio_static_streams PRIVATE source/hal_audio_static.c source/hal_audio_static_external.c) target_include_directories(hal_audio_static_streams PRIVATE source) -target_link_libraries(hal_audio_static_streams PUBLIC hal_audio_interface log) +target_link_libraries(hal_audio_static_streams PUBLIC hal_audio_interface mlek_log) target_compile_definitions(hal_audio_static_streams PRIVATE $<$:HAL_AUDIO_LOOP>) diff --git a/source/hal/source/components/audio/source/hal_audio_static_external.c b/source/hal/source/components/audio/source/hal_audio_static_external.c index c761d3f0a82da9e73481b3cf24c10889f49e894a..db9d3a6d783fb8021d3d4e49bf2e75301ea08687 100644 --- a/source/hal/source/components/audio/source/hal_audio_static_external.c +++ b/source/hal/source/components/audio/source/hal_audio_static_external.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright 2024 Arm Limited and/or its + * SPDX-FileCopyrightText: Copyright 2024-2025 Arm Limited and/or its * affiliates * SPDX-License-Identifier: Apache-2.0 * @@ -17,6 +17,7 @@ */ #include "log_macros.h" #include "hal_audio_static_external.h" +#include /** These functions must be provided to this interface */ __attribute__((weak)) const char* get_sample_data_filename(uint32_t idx) diff --git a/source/hal/source/components/camera/CMakeLists.txt b/source/hal/source/components/camera/CMakeLists.txt index b10ac7c4fa5642ef70d00cd0ede61e3829773489..fdb5af6d654c3742339d81b5dc86c635240a5f94 100644 --- a/source/hal/source/components/camera/CMakeLists.txt +++ b/source/hal/source/components/camera/CMakeLists.txt @@ -1,5 +1,5 @@ #---------------------------------------------------------------------------- -# SPDX-FileCopyrightText: Copyright 2024 Arm Limited and/or +# SPDX-FileCopyrightText: Copyright 2024-2025 Arm Limited and/or # its affiliates # SPDX-License-Identifier: Apache-2.0 # @@ -34,7 +34,7 @@ target_sources(hal_camera_static_images PRIVATE source/hal_camera_static.c source/hal_camera_static_external.c) target_include_directories(hal_camera_static_images PRIVATE source) -target_link_libraries(hal_camera_static_images PUBLIC hal_camera_interface log) +target_link_libraries(hal_camera_static_images PUBLIC hal_camera_interface mlek_log) target_compile_definitions(hal_camera_static_images PRIVATE $<$:HAL_CAMERA_LOOP>) @@ -50,7 +50,7 @@ if (${FVP_VSI_ENABLED}) add_library(hal_camera_vsi STATIC EXCLUDE_FROM_ALL source/hal_camera_vsi.c) target_link_libraries(hal_camera_vsi PUBLIC hal_camera_interface - log + mlek_log virtual_streaming_interface) target_compile_definitions(hal_camera_vsi PRIVATE DYNAMIC_IFM_BASE=${DYNAMIC_IFM_BASE} diff --git a/source/hal/source/components/camera/source/hal_camera_static.c b/source/hal/source/components/camera/source/hal_camera_static.c index f10978eefa1ee285d5bc2ec8407129646da0bdaf..df8d9b2b49e9930c614bb811a617a400f4226869 100644 --- a/source/hal/source/components/camera/source/hal_camera_static.c +++ b/source/hal/source/components/camera/source/hal_camera_static.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright 2024 Arm Limited and/or its + * SPDX-FileCopyrightText: Copyright 2024-2025 Arm Limited and/or its * affiliates * SPDX-License-Identifier: Apache-2.0 * @@ -18,8 +18,9 @@ #include "hal_camera.h" #include "log_macros.h" #include "hal_camera_static_external.h" - +#include #include +#include typedef struct hal_camera_device_ { char name[32]; diff --git a/source/hal/source/components/camera/source/hal_camera_static_external.c b/source/hal/source/components/camera/source/hal_camera_static_external.c index b75b83f2685b2f4d7e02c9d24a4854cf38bf4476..b03d45ba144fce70b0bfede3e13f442bff928fb9 100644 --- a/source/hal/source/components/camera/source/hal_camera_static_external.c +++ b/source/hal/source/components/camera/source/hal_camera_static_external.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright 2024 Arm Limited and/or its + * SPDX-FileCopyrightText: Copyright 2024-2025 Arm Limited and/or its * affiliates * SPDX-License-Identifier: Apache-2.0 * @@ -16,6 +16,8 @@ * limitations under the License. */ #include "log_macros.h" +#include +#include __attribute__((weak)) const char* get_sample_data_filename(uint32_t idx) { diff --git a/source/hal/source/components/lcd/CMakeLists.txt b/source/hal/source/components/lcd/CMakeLists.txt index 6d0aec5ad4d300aaa26f6c1b7aded9ab3c9520d8..d87c4d9ecc0476bba4fe8aefae75228ac87e0153 100644 --- a/source/hal/source/components/lcd/CMakeLists.txt +++ b/source/hal/source/components/lcd/CMakeLists.txt @@ -1,5 +1,5 @@ #---------------------------------------------------------------------------- -# SPDX-FileCopyrightText: Copyright 2022, 2024 Arm Limited and/or +# SPDX-FileCopyrightText: Copyright 2022, 2024-2025 Arm Limited and/or # its affiliates # SPDX-License-Identifier: Apache-2.0 # @@ -60,7 +60,7 @@ target_compile_definitions(${LCD_MPS3_COMPONENT_TARGET} $<$:LCD_TITLE_STRING=\"${LCD_TITLE_STRING}\">) ## Logging utilities: -if (NOT TARGET log) +if (NOT TARGET mlek_log) if (NOT DEFINED LOG_PROJECT_DIR) message(FATAL_ERROR "LOG_PROJECT_DIR needs to be defined.") endif() @@ -70,7 +70,7 @@ endif() ## Add dependencies target_link_libraries(${LCD_MPS3_COMPONENT_TARGET} PUBLIC ${LCD_IFACE_TARGET} - log) + mlek_log) # Display status message(STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR}) @@ -96,7 +96,7 @@ target_sources(${LCD_STUBS_COMPONENT_TARGET} ## Add dependencies target_link_libraries(${LCD_STUBS_COMPONENT_TARGET} PUBLIC ${LCD_IFACE_TARGET} - log) + mlek_log) # Display status message(STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/source/hal/source/components/npu/CMakeLists.txt b/source/hal/source/components/npu/CMakeLists.txt index 6671ed7ec49d1d497140892adf71a5d3c4fbef6d..3fd768f0c377ab5af6131a22c51947271cfbea74 100644 --- a/source/hal/source/components/npu/CMakeLists.txt +++ b/source/hal/source/components/npu/CMakeLists.txt @@ -1,5 +1,5 @@ #---------------------------------------------------------------------------- -# SPDX-FileCopyrightText: Copyright 2022, 2024 Arm Limited and/or its +# SPDX-FileCopyrightText: Copyright 2022, 2024-2025 Arm Limited and/or its # affiliates # SPDX-License-Identifier: Apache-2.0 # @@ -88,7 +88,7 @@ endif () add_subdirectory(${ETHOS_U_NPU_DRIVER_SRC_PATH} ${CMAKE_BINARY_DIR}/ethos-u-driver) ## Logging utilities: -if (NOT TARGET log) +if (NOT TARGET mlek_log) if (NOT DEFINED LOG_PROJECT_DIR) message(FATAL_ERROR "LOG_PROJECT_DIR needs to be defined.") endif() @@ -174,7 +174,7 @@ target_sources(${ETHOS_U_NPU_COMPONENT} ## Add dependencies: target_link_libraries(${ETHOS_U_NPU_COMPONENT} PUBLIC ethosu_core_driver - log) + mlek_log) ## If the rte_components target has been defined, include it as a dependency here. This component ## gives access to certain CPU related functions and definitions that should come from the CMSIS diff --git a/source/hal/source/components/npu_ta/CMakeLists.txt b/source/hal/source/components/npu_ta/CMakeLists.txt index 2030849fc5d50227ed3b66a48117b0a8a9fa3f35..7c70f7f530d44107de3bf3b26ac6fe529ff6daa2 100644 --- a/source/hal/source/components/npu_ta/CMakeLists.txt +++ b/source/hal/source/components/npu_ta/CMakeLists.txt @@ -1,5 +1,5 @@ #---------------------------------------------------------------------------- -# SPDX-FileCopyrightText: Copyright 2022, 2024 Arm Limited and/or its +# SPDX-FileCopyrightText: Copyright 2022, 2024-2025 Arm Limited and/or its # affiliates # SPDX-License-Identifier: Apache-2.0 # @@ -56,7 +56,7 @@ endif() add_subdirectory(${ETHOS_U_NPU_TIMING_ADAPTER_SRC_PATH} ${CMAKE_BINARY_DIR}/timing_adapter) ## Logging utilities: -if (NOT TARGET log) +if (NOT TARGET mlek_log) if (NOT DEFINED LOG_PROJECT_DIR) message(FATAL_ERROR "LOG_PROJECT_DIR needs to be defined.") endif() @@ -85,7 +85,7 @@ target_compile_definitions(${ETHOS_U_NPU_TA_COMPONENT} ## Add dependencies target_link_libraries(${ETHOS_U_NPU_TA_COMPONENT} PUBLIC timing_adapter - log) + mlek_log) # Display status message(STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/source/hal/source/hal.c b/source/hal/source/hal.c index 4a5d88f159a2929f18ea6c9618c3ae7e42270db9..f2f4df9035849a3e706948ab3389655e23507080 100644 --- a/source/hal/source/hal.c +++ b/source/hal/source/hal.c @@ -1,5 +1,6 @@ /* - * SPDX-FileCopyrightText: Copyright 2022 Arm Limited and/or its affiliates + * SPDX-FileCopyrightText: Copyright 2022, 2025 Arm Limited and/or + * its affiliates * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,6 +19,7 @@ #include "platform_drivers.h" /* Platform drivers */ #include "log_macros.h" /* Logging macros */ +#include bool hal_platform_init(void) { diff --git a/source/hal/source/platform/mps3/CMakeLists.txt b/source/hal/source/platform/mps3/CMakeLists.txt index 900ce93f1c77185b15dfa8a6ae83a1339b566889..c895beee062b523eb73b16ab13a1af4c46bd79ed 100644 --- a/source/hal/source/platform/mps3/CMakeLists.txt +++ b/source/hal/source/platform/mps3/CMakeLists.txt @@ -136,7 +136,7 @@ target_include_directories(cmsis_device PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include/${TARGET_SUBSYSTEM}) ## Logging utilities: -if (NOT TARGET log) +if (NOT TARGET mlek_log) if (NOT DEFINED LOG_PROJECT_DIR) message(FATAL_ERROR "LOG_PROJECT_DIR needs to be defined.") endif() @@ -145,7 +145,7 @@ endif() # Add dependencies: target_link_libraries(${PLATFORM_DRIVERS_TARGET} PUBLIC - log + mlek_log cmsis_device platform_pmu lcd_mps3 diff --git a/source/hal/source/platform/mps4/CMakeLists.txt b/source/hal/source/platform/mps4/CMakeLists.txt index 7b671bab5f90c84b57f3183edecd3e4320122825..6d527a0240a2c354182e08f6ee5bb2fafec92ef7 100644 --- a/source/hal/source/platform/mps4/CMakeLists.txt +++ b/source/hal/source/platform/mps4/CMakeLists.txt @@ -114,7 +114,7 @@ target_include_directories(cmsis_device PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include/${TARGET_SUBSYSTEM}) ## Logging utilities: -if (NOT TARGET log) +if (NOT TARGET mlek_log) if (NOT DEFINED LOG_PROJECT_DIR) message(FATAL_ERROR "LOG_PROJECT_DIR needs to be defined.") endif() @@ -123,7 +123,7 @@ endif() # Add dependencies: target_link_libraries(${PLATFORM_DRIVERS_TARGET} PUBLIC - log + mlek_log cmsis_device platform_pmu lcd_stubs diff --git a/source/hal/source/platform/native/CMakeLists.txt b/source/hal/source/platform/native/CMakeLists.txt index 66985ac18e630c3048f8e990d35d5ba32a256922..512fb490152345ab844cbee5f072d0a9f3a74e74 100644 --- a/source/hal/source/platform/native/CMakeLists.txt +++ b/source/hal/source/platform/native/CMakeLists.txt @@ -70,7 +70,7 @@ add_subdirectory(${COMPONENTS_DIR}/audio ${CMAKE_BINARY_DIR}/audio) # Add dependencies: target_link_libraries(${PLATFORM_DRIVERS_TARGET} PUBLIC - log + mlek_log platform_pmu lcd_stubs hal_audio_static_streams diff --git a/source/hal/source/platform/simple/CMakeLists.txt b/source/hal/source/platform/simple/CMakeLists.txt index ca4bb221dbd41122069769649c65aec3db18bd82..83a328d7170869dc73d5ae162a1ade14104d80ba 100644 --- a/source/hal/source/platform/simple/CMakeLists.txt +++ b/source/hal/source/platform/simple/CMakeLists.txt @@ -88,7 +88,7 @@ target_include_directories(cmsis_device PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include/${TARGET_SUBSYSTEM}) ## Logging utilities: -if (NOT TARGET log) +if (NOT TARGET mlek_log) if (NOT DEFINED LOG_PROJECT_DIR) message(FATAL_ERROR "LOG_PROJECT_DIR needs to be defined.") endif() @@ -98,7 +98,7 @@ endif() # Add dependencies: target_link_libraries(${PLATFORM_DRIVERS_TARGET} PUBLIC cmsis_device - log + mlek_log platform_pmu lcd_stubs hal_audio_static_streams diff --git a/source/log/CMakeLists.txt b/source/log/CMakeLists.txt index c0478de156665892ecf0254c0935d02154b4e0f2..e5437b7d4008025aaf8dccba30211f7b43fb601c 100644 --- a/source/log/CMakeLists.txt +++ b/source/log/CMakeLists.txt @@ -1,5 +1,6 @@ #---------------------------------------------------------------------------- -# SPDX-FileCopyrightText: Copyright 2022 Arm Limited and/or its affiliates +# SPDX-FileCopyrightText: Copyright 2022, 2025 Arm Limited and/or +# its affiliates # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -20,24 +21,42 @@ ####################################################### cmake_minimum_required(VERSION 3.21.0) -set(BSP_LOGGING_TARGET log) +set(MLEK_LOG_TARGET mlek_log) -project(${BSP_LOGGING_TARGET} +project(${MLEK_LOG_TARGET} DESCRIPTION "Generic logging formatting header-only interface lib." LANGUAGES C) -add_library(${BSP_LOGGING_TARGET} INTERFACE) +set(MLEK_LOG_ENABLE ON + CACHE BOOL "Enable MLEK logging functions. Set this to off to disable all logging.") -if (DEFINED LOG_LEVEL) - message(STATUS "Setting log level to ${LOG_LEVEL}") - target_compile_definitions(${BSP_LOGGING_TARGET} - INTERFACE - LOG_LEVEL=${LOG_LEVEL}) +set(MLEK_LOG_LEVEL MLEK_LOG_LEVEL_INFO + CACHE STRING "Log level.") + +set_property(CACHE MLEK_LOG_LEVEL PROPERTY STRINGS + MLEK_LOG_LEVEL_TRACE + MLEK_LOG_LEVEL_DEBUG + MLEK_LOG_LEVEL_INFO + MLEK_LOG_LEVEL_WARN + MLEK_LOG_LEVEL_ERROR) + +add_library(${MLEK_LOG_TARGET} INTERFACE) + +if (MLEK_LOG_ENABLE) + target_compile_definitions(${MLEK_LOG_TARGET} INTERFACE + MLEK_LOG_ENABLE) + if (DEFINED MLEK_LOG_LEVEL) + message(STATUS "Setting log level to ${MLEK_LOG_LEVEL}") + target_compile_definitions(${MLEK_LOG_TARGET} INTERFACE + MLEK_LOG_LEVEL=${MLEK_LOG_LEVEL}) + endif() +else() + message(STATUS "MLEK log is disabled") endif() -target_include_directories(${BSP_LOGGING_TARGET} INTERFACE include) +target_include_directories(${MLEK_LOG_TARGET} INTERFACE include) -message(STATUS "*******************************************************") -message(STATUS "Library : " ${BSP_LOGGING_TARGET}) -message(STATUS "CMAKE_SYSTEM_PROCESSOR : " ${CMAKE_SYSTEM_PROCESSOR}) -message(STATUS "*******************************************************") +message(STATUS "**************************************************") +message(STATUS "Library: " ${MLEK_LOG_TARGET}) +message(STATUS "CMAKE_SYSTEM_PROCESSOR: " ${CMAKE_SYSTEM_PROCESSOR}) +message(STATUS "**************************************************") diff --git a/source/log/include/log_macros.h b/source/log/include/log_macros.h index 6c115abcb5f5e39d9c896fd048a85b1891282f48..8a75f76f15e5a3f0dc3fc86795a3d236d066bb47 100644 --- a/source/log/include/log_macros.h +++ b/source/log/include/log_macros.h @@ -1,6 +1,7 @@ /* - * SPDX-FileCopyrightText: Copyright 2021 Arm Limited and/or its affiliates - * SPDX-License-Identifier: Apache-2.0 + * SPDX-FileCopyrightText: Copyright 2021, 2025 Arm Limited and/or + * its affiliates + * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,8 +15,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef ML_EMBEDDED_CORE_LOG_H -#define ML_EMBEDDED_CORE_LOG_H +#ifndef MLEK_BASIC_LOGGER_H +#define MLEK_BASIC_LOGGER_H + +#if !defined(UNUSED) +#define UNUSED(x) ((void)(x)) +#endif /* #if !defined(UNUSED) */ + +#if defined(MLEK_LOG_ENABLE) #ifdef __cplusplus extern "C" { @@ -24,29 +31,26 @@ extern "C" { #include #include -#define LOG_LEVEL_TRACE 0 -#define LOG_LEVEL_DEBUG 1 -#define LOG_LEVEL_INFO 2 -#define LOG_LEVEL_WARN 3 -#define LOG_LEVEL_ERROR 4 +#define MLEK_LOG_LEVEL_TRACE (0) +#define MLEK_LOG_LEVEL_DEBUG (1) +#define MLEK_LOG_LEVEL_INFO (2) +#define MLEK_LOG_LEVEL_WARN (3) +#define MLEK_LOG_LEVEL_ERROR (4) -#ifndef LOG_LEVEL -#define LOG_LEVEL LOG_LEVEL_INFO -#endif /*LOG_LEVEL*/ +#ifndef MLEK_LOG_LEVEL +#define MLEK_LOG_LEVEL MLEK_LOG_LEVEL_INFO +#endif /* MLEK_LOG_LEVEL */ -#if !defined(UNUSED) -#define UNUSED(x) ((void)(x)) -#endif /* #if !defined(UNUSED) */ -#if (LOG_LEVEL == LOG_LEVEL_TRACE) +#if (MLEK_LOG_LEVEL == MLEK_LOG_LEVEL_TRACE) #define trace(...) \ printf("TRACE - "); \ printf(__VA_ARGS__) #else #define trace(...) -#endif /* LOG_LEVEL == LOG_LEVEL_TRACE */ +#endif /* LOG_LEVEL == MLEK_LOG_LEVEL_TRACE */ -#if (LOG_LEVEL <= LOG_LEVEL_DEBUG) +#if (MLEK_LOG_LEVEL <= MLEK_LOG_LEVEL_DEBUG) #define debug(...) \ printf("DEBUG - "); \ printf(__VA_ARGS__) @@ -54,7 +58,7 @@ extern "C" { #define debug(...) #endif /* LOG_LEVEL > LOG_LEVEL_TRACE */ -#if (LOG_LEVEL <= LOG_LEVEL_INFO) +#if (MLEK_LOG_LEVEL <= MLEK_LOG_LEVEL_INFO) #define info(...) \ printf("INFO - "); \ printf(__VA_ARGS__) @@ -62,7 +66,7 @@ extern "C" { #define info(...) #endif /* LOG_LEVEL > LOG_LEVEL_DEBUG */ -#if (LOG_LEVEL <= LOG_LEVEL_WARN) +#if (MLEK_LOG_LEVEL <= MLEK_LOG_LEVEL_WARN) #define warn(...) \ printf("WARN - "); \ printf(__VA_ARGS__) @@ -70,7 +74,7 @@ extern "C" { #define warn(...) #endif /* LOG_LEVEL > LOG_LEVEL_INFO */ -#if (LOG_LEVEL <= LOG_LEVEL_ERROR) +#if (MLEK_LOG_LEVEL <= MLEK_LOG_LEVEL_ERROR) #define printf_err(...) \ printf("ERROR - "); \ printf(__VA_ARGS__) @@ -82,4 +86,32 @@ extern "C" { } #endif -#endif /* ML_EMBEDDED_CORE_LOG_H */ +#else /* defined(MLEK_LOG_ENABLE) */ + +/** + * Logging macros in this file will not be used. + * Provide stubs if the definitions have not been overridden externally. + */ +#if !defined(trace) + #define trace(...) +#endif + +#if !defined(debug) + #define debug(...) +#endif + +#if !defined(info) + #define info(...) +#endif + +#if !defined(warn) + #define warn(...) +#endif + +#if !defined(printf_err) + #define printf_err(...) +#endif + +#endif /* defined(MLEK_LOG_ENABLE) */ + +#endif /* MLEK_BASIC_LOGGER_H */ diff --git a/source/math/CMakeLists.txt b/source/math/CMakeLists.txt index 009389c6d3675126eb5f07e64b3db15ca7fa4f40..9d9d0ada5ae7b29ad22249d5a89852e1a62a1a88 100644 --- a/source/math/CMakeLists.txt +++ b/source/math/CMakeLists.txt @@ -32,7 +32,7 @@ target_sources(arm_math target_include_directories(arm_math PUBLIC include) -target_link_libraries(arm_math PRIVATE log) +target_link_libraries(arm_math PRIVATE mlek_log) if (${CMAKE_CROSSCOMPILING}) include(cmsis-dsp) diff --git a/source/profiler/CMakeLists.txt b/source/profiler/CMakeLists.txt index 5c0a433f7b5a0b4090436fb086eac80612df8623..f537c62b7c5283da1b7ebcce90f506dd0281d94f 100644 --- a/source/profiler/CMakeLists.txt +++ b/source/profiler/CMakeLists.txt @@ -1,5 +1,6 @@ #---------------------------------------------------------------------------- -# SPDX-FileCopyrightText: Copyright 2022 Arm Limited and/or its affiliates +# SPDX-FileCopyrightText: Copyright 2022, 2025 Arm Limited and/or its +# affiliates # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -32,7 +33,7 @@ target_sources(profiler target_include_directories(profiler PUBLIC include) # Profiling API depends on the logging interface and the HAL library. -target_link_libraries(profiler PRIVATE log hal) +target_link_libraries(profiler PRIVATE hal mlek_log) # Display status message(STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR})