LIB: Update secure partitions with new logging API

Change-Id: Ic4651000ac3c22f54f329d0e0aebb41ffb839b34
Signed-off-by: Jackson Cooper-Driver <jackson.cooper-driver@arm.com>
diff --git a/examples/corstone310_fvp_dma/dma350_s/dma350_s_test.c b/examples/corstone310_fvp_dma/dma350_s/dma350_s_test.c
index 1a8a0c6..3ed669d 100644
--- a/examples/corstone310_fvp_dma/dma350_s/dma350_s_test.c
+++ b/examples/corstone310_fvp_dma/dma350_s/dma350_s_test.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022, Arm Limited. All rights reserved.
+ * SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors
  * Copyright (c) 2022 Cypress Semiconductor Corporation (an Infineon company)
  * or an affiliate of Cypress Semiconductor Corporation. All rights reserved.
  *
@@ -10,7 +10,7 @@
 #include "extra_s_tests.h"
 #include "dma350_lib.h"
 #include "platform_base_address.h"
-#include "tfm_sp_log.h"
+#include "tfm_log_unpriv.h"
 
 #include <string.h>
 
diff --git a/examples/example_partition/tfm_example_partition.c b/examples/example_partition/tfm_example_partition.c
index 1539d81..e57b839 100644
--- a/examples/example_partition/tfm_example_partition.c
+++ b/examples/example_partition/tfm_example_partition.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020-2022, Arm Limited. All rights reserved.
+ * SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -9,7 +9,7 @@
 
 #include "psa/service.h"
 #include "psa_manifest/tfm_example_partition.h"
-#include "tfm_sp_log.h"
+#include "tfm_log_unpriv.h"
 
 /**
  * \brief An example service implementation that prints out an argument from the
@@ -38,7 +38,7 @@
 
         /* Print arg from client */
         psa_read(msg->handle, 0, &arg, sizeof(arg));
-        LOG_INFFMT("[Example partition] Service called! arg=%p\r\n", arg);
+        INFO_UNPRIV_RAW("[Example partition] Service called! arg=%x\n", arg);
 
         status = PSA_SUCCESS;
         break;
@@ -56,7 +56,7 @@
  */
 psa_status_t tfm_example_partition_main(void)
 {
-    LOG_INFFMT("Example Partition initializing\r\n");
+    INFO_UNPRIV_RAW("Example Partition initializing\n");
 
     return PSA_SUCCESS;
 }
diff --git a/partitions/dice_protection_environment/CMakeLists.txt b/partitions/dice_protection_environment/CMakeLists.txt
index a2609b8..c111503 100644
--- a/partitions/dice_protection_environment/CMakeLists.txt
+++ b/partitions/dice_protection_environment/CMakeLists.txt
@@ -125,7 +125,7 @@
                                  -DTFM_PATH=${CMAKE_SOURCE_DIR}       # To locate tfm_t_cose.cmake
                                  -DT_COSE_PATH=${T_COSE_PATH}         # External dependency
                                  -DTFM_TEST_PATH=${TFM_TEST_PATH}     # To locate test framework src
-                                 -DTFM_PARTITION_LOG_LEVEL=${TFM_PARTITION_LOG_LEVEL}
+                                 -DLOG_LEVEL_UNPRIV=${TFM_PARTITION_LOG_LEVEL}
                                  $<$<BOOL:${AFL_CC}>:-DCMAKE_C_COMPILER=${AFL_CC}>
                                  $<$<BOOL:${AFL_CC}>:-DFUZZ_TEST=ON>
         COMMAND ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/dpe_host
diff --git a/partitions/dice_protection_environment/dpe_log.c b/partitions/dice_protection_environment/dpe_log.c
index afbd951..0eea2e7 100644
--- a/partitions/dice_protection_environment/dpe_log.c
+++ b/partitions/dice_protection_environment/dpe_log.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023-2024, Arm Limited. All rights reserved.
+ * SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -8,7 +8,7 @@
 #include "dpe_log.h"
 #include "dpe_context_mngr.h"
 
-#if (TFM_PARTITION_LOG_LEVEL >= TFM_PARTITION_LOG_LEVEL_DEBUG)
+#if (LOG_LEVEL_UNPRIV >= LOG_LEVEL_VERBOSE)
 #define LOG_BOOL_VAL(arg)   ((arg) ? "true" : "false")
 
 static void print_byte_array(const uint8_t *array, size_t len)
@@ -18,50 +18,50 @@
     if (array != NULL) {
         for (i = 0; i < len; ++i) {
             if ((i & 0xF) == 0) {
-                LOG_DBGFMT("\r\n   ");
+                VERBOSE_UNPRIV_RAW("\n   ");
             }
             if (array[i] < 0x10) {
-                LOG_DBGFMT(" 0%x", array[i]);
+                VERBOSE_UNPRIV_RAW(" 0%x", array[i]);
             } else {
-                LOG_DBGFMT(" %x", array[i]);
+                VERBOSE_UNPRIV_RAW(" %x", array[i]);
             }
         }
     }
 
-    LOG_DBGFMT("\r\n");
+    VERBOSE_UNPRIV_RAW("\n");
 }
 
 static void log_dice_inputs(const DiceInputValues *input)
 {
-    LOG_DBGFMT(" - DICE code_hash =");
+    VERBOSE_UNPRIV_RAW(" - DICE code_hash =");
     print_byte_array(input->code_hash, sizeof(input->code_hash));
-    LOG_DBGFMT(" - DICE code_descriptor =");
+    VERBOSE_UNPRIV_RAW(" - DICE code_descriptor =");
     print_byte_array(input->code_descriptor, input->code_descriptor_size);
-    LOG_DBGFMT(" - DICE config_type = %d\r\n", input->config_type);
-    LOG_DBGFMT(" - DICE config_value =");
+    VERBOSE_UNPRIV_RAW(" - DICE config_type = %d\n", input->config_type);
+    VERBOSE_UNPRIV_RAW(" - DICE config_value =");
     print_byte_array(input->config_value, sizeof(input->config_value));
-    LOG_DBGFMT(" - DICE config_descriptor =");
+    VERBOSE_UNPRIV_RAW(" - DICE config_descriptor =");
     print_byte_array(input->config_descriptor, input->config_descriptor_size);
-    LOG_DBGFMT(" - DICE authority_hash =");
+    VERBOSE_UNPRIV_RAW(" - DICE authority_hash =");
     print_byte_array(input->authority_hash, sizeof(input->authority_hash));
-    LOG_DBGFMT(" - DICE authority_descriptor =");
+    VERBOSE_UNPRIV_RAW(" - DICE authority_descriptor =");
     print_byte_array(input->authority_descriptor,
                      input->authority_descriptor_size);
-    LOG_DBGFMT(" - DICE mode = %d\r\n", input->mode);
-    LOG_DBGFMT(" - DICE hidden =");
+    VERBOSE_UNPRIV_RAW(" - DICE mode = %d\n", input->mode);
+    VERBOSE_UNPRIV_RAW(" - DICE hidden =");
     print_byte_array(input->hidden, sizeof(input->hidden));
 }
 
 void log_derive_rot_context(const DiceInputValues *dice_inputs)
 {
-    LOG_DBGFMT("DPE DeriveRoTContext:\r\n");
+    VERBOSE_UNPRIV_RAW("DPE DeriveRoTContext:\n");
     log_dice_inputs(dice_inputs);
 }
 
 static void log_handle(int context_handle)
 {
-    LOG_DBGFMT(" index - %d,", GET_IDX(context_handle));
-    LOG_DBGFMT(" nonce - 0x%x\r\n", GET_NONCE(context_handle));
+    VERBOSE_UNPRIV_RAW(" index - %d,", GET_IDX(context_handle));
+    VERBOSE_UNPRIV_RAW(" nonce - 0x%x\n", GET_NONCE(context_handle));
 }
 
 void log_derive_context(int context_handle,
@@ -72,23 +72,23 @@
                         const DiceInputValues *dice_inputs,
                         int32_t client_id)
 {
-    LOG_DBGFMT("DPE DeriveContext:\r\n");
-    LOG_DBGFMT(" - input context handle:");
+    VERBOSE_UNPRIV_RAW("DPE DeriveContext:\n");
+    VERBOSE_UNPRIV_RAW(" - input context handle:");
     log_handle(context_handle);
-    LOG_DBGFMT(" - cert_id = 0x%x\r\n", cert_id);
-    LOG_DBGFMT(" - retain_parent_context = %s\r\n", LOG_BOOL_VAL(retain_parent_context));
-    LOG_DBGFMT(" - allow_new_context_to_derive = %s\r\n", LOG_BOOL_VAL(allow_new_context_to_derive));
-    LOG_DBGFMT(" - create_certificate = %s\r\n", LOG_BOOL_VAL(create_certificate));
+    VERBOSE_UNPRIV_RAW(" - cert_id = 0x%x\n", cert_id);
+    VERBOSE_UNPRIV_RAW(" - retain_parent_context = %s\n", LOG_BOOL_VAL(retain_parent_context));
+    VERBOSE_UNPRIV_RAW(" - allow_new_context_to_derive = %s\n", LOG_BOOL_VAL(allow_new_context_to_derive));
+    VERBOSE_UNPRIV_RAW(" - create_certificate = %s\n", LOG_BOOL_VAL(create_certificate));
     log_dice_inputs(dice_inputs);
-    LOG_DBGFMT(" - client_id = %d\r\n", client_id);
+    VERBOSE_UNPRIV_RAW(" - client_id = %d\n", client_id);
 }
 
 void log_destroy_context(int context_handle, bool destroy_recursively)
 {
-    LOG_DBGFMT("DPE DestroyContext:\r\n");
-    LOG_DBGFMT(" - input context handle:");
+    VERBOSE_UNPRIV_RAW("DPE DestroyContext:\n");
+    VERBOSE_UNPRIV_RAW(" - input context handle:");
     log_handle(context_handle);
-    LOG_DBGFMT(" - destroy_recursively = %s\r\n", LOG_BOOL_VAL(destroy_recursively));
+    VERBOSE_UNPRIV_RAW(" - destroy_recursively = %s\n", LOG_BOOL_VAL(destroy_recursively));
 }
 
 void log_certify_key(int context_handle,
@@ -98,13 +98,13 @@
                      const uint8_t *label,
                      size_t label_size)
 {
-    LOG_DBGFMT("DPE CertifyKey:\r\n");
-    LOG_DBGFMT(" - input context handle:");
+    VERBOSE_UNPRIV_RAW("DPE CertifyKey:\n");
+    VERBOSE_UNPRIV_RAW(" - input context handle:");
     log_handle(context_handle);
-    LOG_DBGFMT(" - retain_context = %s\r\n", LOG_BOOL_VAL(retain_context));
-    LOG_DBGFMT(" - public_key =");
+    VERBOSE_UNPRIV_RAW(" - retain_context = %s\n", LOG_BOOL_VAL(retain_context));
+    VERBOSE_UNPRIV_RAW(" - public_key =");
     print_byte_array(public_key, public_key_size);
-    LOG_DBGFMT(" - label =");
+    VERBOSE_UNPRIV_RAW(" - label =");
     print_byte_array(label, label_size);
 }
 
@@ -113,82 +113,82 @@
                                bool clear_from_context,
                                size_t cert_chain_buf_size)
 {
-    LOG_DBGFMT("DPE GetCertificateChain:\r\n");
-    LOG_DBGFMT(" - input context handle:");
+    VERBOSE_UNPRIV_RAW("DPE GetCertificateChain:\n");
+    VERBOSE_UNPRIV_RAW(" - input context handle:");
     log_handle(context_handle);
-    LOG_DBGFMT(" - retain_context = %s\r\n", LOG_BOOL_VAL(retain_context));
-    LOG_DBGFMT(" - clear_from_context = %s\r\n", LOG_BOOL_VAL(clear_from_context));
-    LOG_DBGFMT(" - cert_chain_buf_size = %d\r\n", cert_chain_buf_size);
+    VERBOSE_UNPRIV_RAW(" - retain_context = %s\n", LOG_BOOL_VAL(retain_context));
+    VERBOSE_UNPRIV_RAW(" - clear_from_context = %s\n", LOG_BOOL_VAL(clear_from_context));
+    VERBOSE_UNPRIV_RAW(" - cert_chain_buf_size = %d\n", cert_chain_buf_size);
 }
 
 void log_intermediate_certificate(const uint8_t *cert_buf,
                                   size_t cert_size)
 {
-    LOG_DBGFMT("DPE Intermediate Certificate:\r\n");
-    LOG_DBGFMT(" - size = %d\r\n", cert_size);
-    LOG_DBGFMT(" - certificate =");
+    VERBOSE_UNPRIV_RAW("DPE Intermediate Certificate:\n");
+    VERBOSE_UNPRIV_RAW(" - size = %d\n", cert_size);
+    VERBOSE_UNPRIV_RAW(" - certificate =");
     print_byte_array(cert_buf, cert_size);
 }
 
 void log_certificate_chain(const uint8_t *certificate_chain_buf,
                            size_t certificate_chain_size)
 {
-    LOG_DBGFMT("DPE Certificate Chain:\r\n");
-    LOG_DBGFMT(" - size = %d\r\n", certificate_chain_size);
+    VERBOSE_UNPRIV_RAW("DPE Certificate Chain:\n");
+    VERBOSE_UNPRIV_RAW(" - size = %d\n", certificate_chain_size);
     print_byte_array(certificate_chain_buf, certificate_chain_size);
 }
 
 void log_derive_context_output_handles(int parent_context_handle,
                                        int new_context_handle)
 {
-    LOG_DBGFMT("DPE DeriveContext output handles:\r\n");
-    LOG_DBGFMT(" - parent context handle:");
+    VERBOSE_UNPRIV_RAW("DPE DeriveContext output handles:\n");
+    VERBOSE_UNPRIV_RAW(" - parent context handle:");
     log_handle(parent_context_handle);
-    LOG_DBGFMT(" - new context handle:");
+    VERBOSE_UNPRIV_RAW(" - new context handle:");
     log_handle(new_context_handle);
 }
 
 void log_certify_key_output_handle(int new_context_handle)
 {
-    LOG_DBGFMT("DPE CertifyKey output handle:\r\n");
-    LOG_DBGFMT(" - new context handle:");
+    VERBOSE_UNPRIV_RAW("DPE CertifyKey output handle:\n");
+    VERBOSE_UNPRIV_RAW(" - new context handle:");
     log_handle(new_context_handle);
 }
 
 void log_get_certificate_chain_output_handle(int new_context_handle)
 {
-    LOG_DBGFMT("DPE GetCertificateChain output handle:\r\n");
-    LOG_DBGFMT(" - new context handle:");
+    VERBOSE_UNPRIV_RAW("DPE GetCertificateChain output handle:\n");
+    VERBOSE_UNPRIV_RAW(" - new context handle:");
     log_handle(new_context_handle);
 }
 
 void log_dpe_component_ctx_metadata(const struct component_context_t *ctx_ptr,
                                     int component_index)
 {
-    LOG_DBGFMT(" DPE component_ctx_array[%d]: \r\n", component_index);
-    LOG_DBGFMT("  - in_use = %s\r\n", LOG_BOOL_VAL(ctx_ptr->in_use));
-    LOG_DBGFMT("  - is_allowed_to_derive = %s\r\n",
+    VERBOSE_UNPRIV_RAW(" DPE component_ctx_array[%d]: \n", component_index);
+    VERBOSE_UNPRIV_RAW("  - in_use = %s\n", LOG_BOOL_VAL(ctx_ptr->in_use));
+    VERBOSE_UNPRIV_RAW("  - is_allowed_to_derive = %s\n",
                 LOG_BOOL_VAL(ctx_ptr->is_allowed_to_derive));
-    LOG_DBGFMT("  - is_export_cdi_allowed = %s\r\n",
+    VERBOSE_UNPRIV_RAW("  - is_export_cdi_allowed = %s\n",
                 LOG_BOOL_VAL(ctx_ptr->is_export_cdi_allowed));
-    LOG_DBGFMT("  - nonce = 0x%x\r\n", ctx_ptr->nonce);
-    LOG_DBGFMT("  - target_locality = %d\r\n", ctx_ptr->target_locality);
-    LOG_DBGFMT("  - expected_mhu_id = %u\r\n", ctx_ptr->expected_mhu_id);
-    LOG_DBGFMT("  - parent_comp_ctx->nonce = %d\r\n", ctx_ptr->parent_comp_ctx->nonce);
+    VERBOSE_UNPRIV_RAW("  - nonce = 0x%x\n", ctx_ptr->nonce);
+    VERBOSE_UNPRIV_RAW("  - target_locality = %d\n", ctx_ptr->target_locality);
+    VERBOSE_UNPRIV_RAW("  - expected_mhu_id = %u\n", ctx_ptr->expected_mhu_id);
+    VERBOSE_UNPRIV_RAW("  - parent_comp_ctx->nonce = %d\n", ctx_ptr->parent_comp_ctx->nonce);
     if (ctx_ptr->linked_cert_ctx != NULL) {
-        LOG_DBGFMT("  - linked_cert_ctx->cert_id = %d\r\n",
+        VERBOSE_UNPRIV_RAW("  - linked_cert_ctx->cert_id = %d\n",
                    ctx_ptr->linked_cert_ctx->cert_id);
     }
 }
 
 void log_dpe_cert_ctx_metadata(const struct cert_context_t *ctx_ptr)
 {
-    LOG_DBGFMT(" DPE cert_ctx_array[]: \r\n");
-    LOG_DBGFMT("  - cert_id = 0x%x\r\n", ctx_ptr->cert_id);
-    LOG_DBGFMT("  - state = %d\r\n", ctx_ptr->state);
-    LOG_DBGFMT("  - is_external_pub_key_provided = %s\r\n",
+    VERBOSE_UNPRIV_RAW(" DPE cert_ctx_array[]: \n");
+    VERBOSE_UNPRIV_RAW("  - cert_id = 0x%x\n", ctx_ptr->cert_id);
+    VERBOSE_UNPRIV_RAW("  - state = %d\n", ctx_ptr->state);
+    VERBOSE_UNPRIV_RAW("  - is_external_pub_key_provided = %s\n",
                 LOG_BOOL_VAL(ctx_ptr->is_external_pub_key_provided));
-    LOG_DBGFMT("  - is_cdi_to_be_exported = %s\r\n",
+    VERBOSE_UNPRIV_RAW("  - is_cdi_to_be_exported = %s\n",
                 LOG_BOOL_VAL(ctx_ptr->is_cdi_to_be_exported));
 }
 
@@ -214,4 +214,4 @@
     }
 }
 
-#endif /* TFM_PARTITION_LOG_LEVEL */
+#endif /* LOG_LEVEL_UNPRIV */
diff --git a/partitions/dice_protection_environment/dpe_log.h b/partitions/dice_protection_environment/dpe_log.h
index 68b1871..8257aae 100644
--- a/partitions/dice_protection_environment/dpe_log.h
+++ b/partitions/dice_protection_environment/dpe_log.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023-2024, Arm Limited. All rights reserved.
+ * SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -10,13 +10,13 @@
 
 #include "dice_protection_environment.h"
 #include "dpe_context_mngr.h"
-#include "tfm_sp_log.h"
+#include "tfm_log_unpriv.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-#if (TFM_PARTITION_LOG_LEVEL >= TFM_PARTITION_LOG_LEVEL_DEBUG)
+#if (LOG_LEVEL_UNPRIV >= LOG_LEVEL_VERBOSE)
 
 /**
  * \brief Log the derive rot context command parameters.
@@ -108,7 +108,7 @@
                                uint8_t *new_certificate_buf,
                                size_t *new_certificate_actual_size);
 
-#else /* TFM_PARTITION_LOG_LEVEL */
+#else /* LOG_LEVEL_UNPRIV */
 
 #define log_derive_rot_context(...)
 #define log_derive_context(...)
@@ -124,7 +124,7 @@
 #define log_dpe_cert_ctx_metadata(...)
 #define log_derive_context_output(...)
 
-#endif /* TFM_PARTITION_LOG_LEVEL */
+#endif /* LOG_LEVEL_UNPRIV */
 
 #ifdef __cplusplus
 }
diff --git a/partitions/dice_protection_environment/test/host/CMakeLists.txt b/partitions/dice_protection_environment/test/host/CMakeLists.txt
index 1a5040f..89ed028 100644
--- a/partitions/dice_protection_environment/test/host/CMakeLists.txt
+++ b/partitions/dice_protection_environment/test/host/CMakeLists.txt
@@ -86,7 +86,6 @@
         ../..
         ${TFM_PATH}/platform/ext/target/arm/rse/common       # platform_locality.h
         ${TFM_PATH}/platform/ext/target/arm/rse/common/dpe   # dpe_plat.h
-        ${TFM_PATH}/secure_fw/partitions/lib/runtime/include # tfm_sp_log.h
     PRIVATE
         ${TFM_PATH}/secure_fw/include                        # array.h
 
@@ -102,7 +101,7 @@
 
 target_compile_definitions(dpe_lib
     PUBLIC
-        TFM_PARTITION_LOG_LEVEL=${TFM_PARTITION_LOG_LEVEL}
+        LOG_LEVEL_UNPRIV=${TFM_PARTITION_LOG_LEVEL}
     PRIVATE
         DPE_TEST_MODE
 )
diff --git a/partitions/dice_protection_environment/test/host/cmd.c b/partitions/dice_protection_environment/test/host/cmd.c
index 314b0bd..d913953 100644
--- a/partitions/dice_protection_environment/test/host/cmd.c
+++ b/partitions/dice_protection_environment/test/host/cmd.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2024, Arm Limited. All rights reserved.
+ * SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -24,7 +24,7 @@
 #include "dpe_test_data.h"
 #include "dpe_test_private.h"
 
-#include "tfm_sp_log.h"
+#include "tfm_log_unpriv.h"
 
 #define CLIENT_ID_NS -1
 
@@ -121,17 +121,17 @@
     if (buf != NULL) {
         for (i = 0; i < size; ++i) {
             if ((i & 0xF) == 0) {
-                LOG_DBGFMT("\r\n");
+                VERBOSE_UNPRIV_RAW("\n");
             }
             if (buf[i] < 0x10) {
-                LOG_DBGFMT(" 0%x", buf[i]);
+                VERBOSE_UNPRIV_RAW(" 0%x", buf[i]);
             } else {
-                LOG_DBGFMT(" %x", buf[i]);
+                VERBOSE_UNPRIV_RAW(" %x", buf[i]);
             }
         }
     }
-    LOG_DBGFMT("\r\n");
-    LOG_DBGFMT("\r\n");
+    VERBOSE_UNPRIV_RAW("\n");
+    VERBOSE_UNPRIV_RAW("\n");
 }
 
 static void build_internal_state(int *context_handle, unsigned char test_data_id)
@@ -139,7 +139,7 @@
     struct test_result_t test_ret = {0};
     int err;
 
-    LOG_DBGFMT("\nDeriving RoT context:\n");
+    VERBOSE_UNPRIV_RAW("\nDeriving RoT context:\n");
     derive_rot_certificate_context(&test_ret);
     if (test_ret.val != TEST_PASSED) {
         printf("ERROR: RoT context derivation failed\n");
@@ -147,16 +147,16 @@
     }
 
     if (test_data_id < ARRAY_SIZE(test_data)) {
-        LOG_DBGFMT("\nBuilding internal state: test_data[%d]\n", test_data_id);
+        VERBOSE_UNPRIV_RAW("\nBuilding internal state: test_data[%d]\n", test_data_id);
         err = build_certificate_chain(&test_data[test_data_id]);
         if (err) {
             printf("\nERROR: Building certificate chain based on test data failed: %d\n", err);
             exit(1);
         }
-        LOG_DBGFMT("Building internal state: Done\n\n");
+        VERBOSE_UNPRIV_RAW("Building internal state: Done\n\n");
         *context_handle = get_last_context_handle(&test_data[test_data_id]);
     } else {
-        LOG_DBGFMT("Building internal state: No\n\n");
+        VERBOSE_UNPRIV_RAW("Building internal state: No\n\n");
         *context_handle = retained_rot_ctx_handle;
     }
 }
@@ -207,14 +207,14 @@
 
     (void)context_handle;
 
-    LOG_DBGFMT("DPE request (%ld):\n", cmd_in_size);
+    VERBOSE_UNPRIV_RAW("DPE request (%ld):\n", cmd_in_size);
     print_buf(cmd_in_buf, cmd_in_size);
 
     err = dpe_command_decode(CLIENT_ID_NS,
                              cmd_in_buf, cmd_in_size,
                              cmd_out_buf, &cmd_out_size);
 
-    LOG_DBGFMT("DPE response (%ld):\n", cmd_out_size);
+    VERBOSE_UNPRIV_RAW("DPE response (%ld):\n", cmd_out_size);
     print_buf(cmd_out_buf, cmd_out_size);
 
     return err;
@@ -271,13 +271,13 @@
     err = CALL_DERIVE_CONTEXT(dc_input, dc_output);
 
     if (dc_output.certificate_actual_size > 0) {
-            LOG_DBGFMT("Certificate:\n");
+            VERBOSE_UNPRIV_RAW("Certificate:\n");
             print_buf(dc_output.certificate_buf,
                       dc_output.certificate_actual_size);
     }
 
     if (dc_output.exported_cdi_actual_size > 0) {
-            LOG_DBGFMT("CDIs:\n");
+            VERBOSE_UNPRIV_RAW("CDIs:\n");
             print_buf(dc_output.exported_cdi_buf,
                       dc_output.exported_cdi_actual_size);
     }
@@ -325,13 +325,13 @@
     err = CALL_CERTIFY_KEY(ck_input, ck_output);
 
     if (ck_output.certificate_chain_actual_size > 0) {
-            LOG_DBGFMT("Certificate:\n");
+            VERBOSE_UNPRIV_RAW("Certificate:\n");
             print_buf(ck_output.certificate_chain_buf,
                       ck_output.certificate_chain_actual_size);
     }
 
     if (ck_output.derived_public_key_actual_size > 0) {
-            LOG_DBGFMT("Public key:\n");
+            VERBOSE_UNPRIV_RAW("Public key:\n");
             print_buf(ck_output.derived_public_key_buf,
                       ck_output.derived_public_key_actual_size);
     }
@@ -375,7 +375,7 @@
                                     &new_context_handle);
 
     if (cert_size > 0) {
-            LOG_DBGFMT("Certificate:\n");
+            VERBOSE_UNPRIV_RAW("Certificate:\n");
             print_buf(cert_buf, cert_size);
     }
 
diff --git a/partitions/dice_protection_environment/test/host/main.c b/partitions/dice_protection_environment/test/host/main.c
index e2cc588..43a435e 100644
--- a/partitions/dice_protection_environment/test/host/main.c
+++ b/partitions/dice_protection_environment/test/host/main.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2024, Arm Limited. All rights reserved.
+ * SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -10,7 +10,7 @@
 #include <stdlib.h>
 
 #include "dice_protection_environment.h"
-#include "tfm_sp_log.h"
+#include "tfm_log_unpriv.h"
 
 #include "extra_s_tests.h"
 #include "test_framework.h"
@@ -108,7 +108,7 @@
 
     } else if (argc == 3) {
         /****************** Input params are provided *************************/
-        LOG_INFFMT("Execute DPE API test (%s %s)\n", argv[1], argv[2]);
+        INFO_UNPRIV_RAW("Execute DPE API test (%s %s)\n", argv[1], argv[2]);
         ret = read_cmd(argv[2], cmd_in_buf, &cmd_in_size);
         if (ret < 0) {
             exit(1);
diff --git a/partitions/dice_protection_environment/test/host/plat.c b/partitions/dice_protection_environment/test/host/plat.c
index 3be08bd..043d0a6 100644
--- a/partitions/dice_protection_environment/test/host/plat.c
+++ b/partitions/dice_protection_environment/test/host/plat.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2024, Arm Limited. All rights reserved.
+ * SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -8,7 +8,7 @@
 #include <stdio.h>
 
 #include "dpe_plat.h"
-#include "tfm_sp_log.h"
+#include "tfm_log_unpriv.h"
 
 extern psa_key_id_t rot_cdi_id;
 extern psa_key_id_t root_attest_key_id;
diff --git a/partitions/dma350_unpriv_partition/tfm_dma350_example_partition.c b/partitions/dma350_unpriv_partition/tfm_dma350_example_partition.c
index 034c7df..55a5e9d 100644
--- a/partitions/dma350_unpriv_partition/tfm_dma350_example_partition.c
+++ b/partitions/dma350_unpriv_partition/tfm_dma350_example_partition.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020-2022, Arm Limited. All rights reserved.
+ * SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -11,7 +11,7 @@
 
 #include "psa/service.h"
 #include "psa_manifest/tfm_dma350_example_partition.h"
-#include "tfm_sp_log.h"
+#include "tfm_log_unpriv.h"
 
 #include "dma350_privileged_config.h"
 #include "dma350_lib.h"
@@ -30,12 +30,12 @@
     enum dma350_lib_error_t status;
     union dma350_ch_status_t ch_status;
 
-    LOG_INFFMT("[DMA-350 Partition] Wrong channel test\r\n");
+    INFO_UNPRIV_RAW("[DMA-350 Partition] Wrong channel test\n");
 
     /* Channel 22 is not a valid channel number */
     status = dma350_ch_get_status_unpriv(22, &ch_status);
     if (status != DMA350_LIB_ERR_CHANNEL_INVALID) {
-        LOG_INFFMT("[DMA-350 Partition] Unexpected dma350_ch_get_status_unpriv return value (%d), expected: %d\r\n",
+        INFO_UNPRIV_RAW("[DMA-350 Partition] Unexpected dma350_ch_get_status_unpriv return value (%d), expected: %d\n",
                    status, DMA350_LIB_ERR_CHANNEL_INVALID);
         return true;
     }
@@ -43,12 +43,12 @@
     /* Channel 1 is not accessable by unprivileged */
     status = dma350_ch_get_status_unpriv(1, &ch_status);
     if (status != DMA350_LIB_ERR_RANGE_NOT_ACCESSIBLE) {
-        LOG_INFFMT("[DMA-350 Partition] Unexpected dma350_ch_get_status_unpriv return value (%d), expected: %d\r\n",
+        INFO_UNPRIV_RAW("[DMA-350 Partition] Unexpected dma350_ch_get_status_unpriv return value (%d), expected: %d\n",
                    status, DMA350_LIB_ERR_RANGE_NOT_ACCESSIBLE);
         return true;
     }
 
-    LOG_INFFMT("[DMA-350 Partition] Test success!\r\n\r\n");
+    INFO_UNPRIV_RAW("[DMA-350 Partition] Test success!\r\n\n");
     return false;
 }
 
@@ -56,7 +56,7 @@
 {
     enum dma350_lib_error_t status;
 
-    LOG_INFFMT("[DMA-350 Partition] Blocking memcopy test\r\n");
+    INFO_UNPRIV_RAW("[DMA-350 Partition] Blocking memcopy test\n");
 
     /* Blocking unprivileged usage of the DMA in our reference solution is
      * prohibited, as the request is processed within an SVC handler context */
@@ -66,12 +66,12 @@
                                      DMA350_LIB_EXEC_BLOCKING);
 
     if (status != DMA350_LIB_ERR_CFG_ERR) {
-        LOG_INFFMT("[DMA-350 Partition] Unexpected dma350_memcpy_unpriv return value (%d), expected: %d\r\n",
+        INFO_UNPRIV_RAW("[DMA-350 Partition] Unexpected dma350_memcpy_unpriv return value (%d), expected: %d\n",
                    status, DMA350_LIB_ERR_CFG_ERR);
         return true;
     }
 
-    LOG_INFFMT("[DMA-350 Partition] Test success!\r\n\r\n");
+    INFO_UNPRIV_RAW("[DMA-350 Partition] Test success!\r\n\n");
     return false;
 }
 
@@ -79,7 +79,7 @@
 {
     enum dma350_lib_error_t status;
 
-    LOG_INFFMT("[DMA-350 Partition] Non-blocking memcopy with privileged address test\r\n");
+    INFO_UNPRIV_RAW("[DMA-350 Partition] Non-blocking memcopy with privileged address test\n");
 
     /* Access for privileged memory should be rejected. */
     status = dma350_memcpy_unpriv(0, (void *)&REGION_NAME(Image$$, ER_TFM_DATA, $$Base),
@@ -88,12 +88,12 @@
                                      DMA350_LIB_EXEC_IRQ);
 
     if (status != DMA350_LIB_ERR_RANGE_NOT_ACCESSIBLE) {
-        LOG_INFFMT("[DMA-350 Partition] Unexpected dma350_memcpy_unpriv return value (%d), expected: %d\r\n",
+        INFO_UNPRIV_RAW("[DMA-350 Partition] Unexpected dma350_memcpy_unpriv return value (%d), expected: %d\n",
                    status, DMA350_LIB_ERR_RANGE_NOT_ACCESSIBLE);
         return true;
     }
 
-    LOG_INFFMT("[DMA-350 Partition] Test success!\r\n\r\n");
+    INFO_UNPRIV_RAW("[DMA-350 Partition] Test success!\r\n\n");
     return false;
 }
 
@@ -102,7 +102,7 @@
     enum dma350_lib_error_t status;
     union dma350_ch_status_t ch_status;
 
-    LOG_INFFMT("[DMA-350 Partition] Non-blocking memcopy test\r\n");
+    INFO_UNPRIV_RAW("[DMA-350 Partition] Non-blocking memcopy test\n");
 
     /* Clear destination */
     memset(DMA350_TEST_MEMORY_TO, '.', DMA350_TEST_COPY_COUNT);
@@ -115,25 +115,25 @@
                                      DMA350_LIB_EXEC_IRQ);
 
     if (status != DMA350_LIB_ERR_NONE) {
-        LOG_INFFMT("[DMA-350 Partition] Memcpy failed (%d)\r\n", status);
+        INFO_UNPRIV_RAW("[DMA-350 Partition] Memcpy failed (%d)\n", status);
         psa_irq_disable(TFM_DMA0_CH0_IRQ_SIGNAL);
         return true;
     } else {
-        LOG_INFFMT("[DMA-350 Partition] Waiting for DMA0 CH0 interrupt..\r\n");
+        INFO_UNPRIV_RAW("[DMA-350 Partition] Waiting for DMA0 CH0 interrupt..\n");
         if (psa_wait(TFM_DMA0_CH0_IRQ_SIGNAL, PSA_BLOCK) != TFM_DMA0_CH0_IRQ_SIGNAL) {
             psa_panic();
         }
-        LOG_INFFMT("[DMA-350 Partition] DMA0 CH0 interrupt received.\r\n");
+        INFO_UNPRIV_RAW("[DMA-350 Partition] DMA0 CH0 interrupt received.\n");
 
         /* Check if the operation is completed without error */
         status = dma350_ch_get_status_unpriv(0, &ch_status);
         if (status != DMA350_LIB_ERR_NONE) {
-            LOG_INFFMT("[DMA-350 Partition] Couldn't get status (%d)\r\n",
+            INFO_UNPRIV_RAW("[DMA-350 Partition] Couldn't get status (%d)\n",
                        status);
             return true;
         }
         if (!ch_status.b.STAT_DONE || ch_status.b.STAT_ERR) {
-            LOG_INFFMT("[DMA-350 Partition] Channel not finished properly. Status: 0x%x\r\n",
+            INFO_UNPRIV_RAW("[DMA-350 Partition] Channel not finished properly. Status: 0x%x\n",
                        ch_status.w);
             return true;
         }
@@ -141,7 +141,7 @@
         /* Clear channel irq */
         status = dma350_clear_done_irq_unpriv(0);
         if (status != DMA350_LIB_ERR_NONE) {
-            LOG_INFFMT("[DMA-350 Partition] Couldn't clear irq (%d)\r\n",
+            INFO_UNPRIV_RAW("[DMA-350 Partition] Couldn't clear irq (%d)\n",
                        status);
             return true;
         }
@@ -152,12 +152,12 @@
         /* Verify results */
         if (strncmp(DMA350_TEST_MEMORY_FROM, DMA350_TEST_MEMORY_TO,
                         DMA350_TEST_COPY_COUNT)) {
-            LOG_INFFMT("[DMA-350 Partition] Copied data mismatch\r\n");
+            INFO_UNPRIV_RAW("[DMA-350 Partition] Copied data mismatch\n");
             return true;
         }
     }
 
-    LOG_INFFMT("[DMA-350 Partition] Test success!\r\n\r\n");
+    INFO_UNPRIV_RAW("[DMA-350 Partition] Test success!\r\n\n");
     return false;
 }
 
@@ -170,24 +170,24 @@
     bool failed = false;
 
     if(test_wrong_channel()) {
-        LOG_ERRFMT("[DMA-350 Partition] Wrong channel test failed\r\n");
+        ERROR_UNPRIV_RAW("[DMA-350 Partition] Wrong channel test failed\n");
         failed = true;
     }
     if(test_memcopy_blocking()) {
-        LOG_ERRFMT("[DMA-350 Partition] Blocking memcopy test failed\r\n");
+        ERROR_UNPRIV_RAW("[DMA-350 Partition] Blocking memcopy test failed\n");
         failed = true;
     }
     if(test_memcopy_non_blocking_priv_address()) {
-        LOG_ERRFMT("[DMA-350 Partition] Non-blocking memcopy with privileged address test failed\r\n");
+        ERROR_UNPRIV_RAW("[DMA-350 Partition] Non-blocking memcopy with privileged address test failed\n");
         failed = true;
     }
     if(test_memcopy_non_blocking()) {
-        LOG_ERRFMT("[DMA-350 Partition] Non-blocking memcopy test failed\r\n");
+        ERROR_UNPRIV_RAW("[DMA-350 Partition] Non-blocking memcopy test failed\n");
         failed = true;
     }
 
     if(!failed) {
-        LOG_INFFMT("[DMA-350 Partition] All tests passed\r\n\r\n");
+        INFO_UNPRIV_RAW("[DMA-350 Partition] All tests passed\r\n\n");
     }
 
     /*
diff --git a/partitions/measured_boot/measured_boot.c b/partitions/measured_boot/measured_boot.c
index c104ced..6f4daf9 100644
--- a/partitions/measured_boot/measured_boot.c
+++ b/partitions/measured_boot/measured_boot.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022-2023, Arm Limited. All rights reserved.
+ * SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -13,7 +13,7 @@
 #include "boot_hal.h"
 #include "service_api.h"
 #include "tfm_strnlen.h"
-#include "tfm_sp_log.h"
+#include "tfm_log_unpriv.h"
 #include <stdint.h>
 #include <string.h>
 #include <stdbool.h>
@@ -358,9 +358,9 @@
 
 error:
     if (status != PSA_SUCCESS) {
-        LOG_DBGFMT("Measured Boot : measurement extension failed.\r\n");
+        VERBOSE_UNPRIV_RAW("Measured Boot : measurement extension failed.\n");
     } else {
-        LOG_DBGFMT("Measured Boot : measurement extended successfully.\r\n");
+        VERBOSE_UNPRIV_RAW("Measured Boot : measurement extended successfully.\n");
     }
 
     return status;
diff --git a/partitions/measured_boot/measured_boot_req_mngr.c b/partitions/measured_boot/measured_boot_req_mngr.c
index 3a69d21..83157b2 100644
--- a/partitions/measured_boot/measured_boot_req_mngr.c
+++ b/partitions/measured_boot/measured_boot_req_mngr.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022-2023, Arm Limited. All rights reserved.
+ * SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -8,7 +8,7 @@
 #include <string.h>
 #include "measured_boot.h"
 #include "measured_boot_defs.h"
-#include "tfm_sp_log.h"
+#include "tfm_log_unpriv.h"
 
 #include "psa/service.h"
 #include "psa_manifest/pid.h"
@@ -165,7 +165,7 @@
     /* Initialise all measurements & related metadata */
     initialise_all_measurements();
 
-    LOG_DBGFMT("Measured Boot : selected algorithm: %x\r\n",
+    VERBOSE_UNPRIV_RAW("Measured Boot : selected algorithm: %x\n",
                TFM_MEASURED_BOOT_HASH_ALG);
 
 #ifdef CONFIG_TFM_BOOT_STORE_MEASUREMENTS
diff --git a/partitions/measured_boot/measured_boot_utils.c b/partitions/measured_boot/measured_boot_utils.c
index 4f13c31..e6f79e6 100644
--- a/partitions/measured_boot/measured_boot_utils.c
+++ b/partitions/measured_boot/measured_boot_utils.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022, Arm Limited. All rights reserved.
+ * SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -7,7 +7,7 @@
 
 #include "measured_boot_utils.h"
 #include "measured_boot_api.h"
-#include "tfm_sp_log.h"
+#include "tfm_log_unpriv.h"
 #include <stddef.h>
 #include <stdint.h>
 #include <string.h>
@@ -17,18 +17,18 @@
     size_t i;
 
     if (array == NULL || len == 0) {
-        LOG_DBGFMT("\r\n");
+        VERBOSE_UNPRIV_RAW("\n");
     } else {
         for (i = 0; i < len; ++i) {
             if (array[i] < 0x10) {
-               LOG_DBGFMT(" 0%x", array[i]);
+               VERBOSE_UNPRIV_RAW(" 0%x", array[i]);
             } else {
-                LOG_DBGFMT(" %x", array[i]);
+                VERBOSE_UNPRIV_RAW(" %x", array[i]);
             }
             if ((i & 0xFu) == 0xFu) {
-                LOG_DBGFMT("\r\n");
+                VERBOSE_UNPRIV_RAW("\n");
                 if (i < (len - 1)) {
-                    LOG_DBGFMT("               :");
+                    VERBOSE_UNPRIV_RAW("               :");
                 }
             }
         }
@@ -58,16 +58,16 @@
     uint8_t string_buf[((SW_TYPE_MAX_SIZE > VERSION_MAX_SIZE) ?
                          SW_TYPE_MAX_SIZE : VERSION_MAX_SIZE) + 1];
 
-    LOG_DBGFMT("Measured Boot : store and extend measurement:\r\n");
-    LOG_DBGFMT(" - slot        : %u\r\n", index);
-    LOG_DBGFMT(" - signer_id   :");
+    VERBOSE_UNPRIV_RAW("Measured Boot : store and extend measurement:\n");
+    VERBOSE_UNPRIV_RAW(" - slot        : %u\n", index);
+    VERBOSE_UNPRIV_RAW(" - signer_id   :");
     print_byte_array(signer_id, signer_id_size);
     add_null_terminator(string_buf, version, version_size);
-    LOG_DBGFMT(" - version     : %s\r\n", string_buf);
-    LOG_DBGFMT(" - algorithm   : %x\r\n", measurement_algo);
+    VERBOSE_UNPRIV_RAW(" - version     : %s\n", string_buf);
+    VERBOSE_UNPRIV_RAW(" - algorithm   : %x\n", measurement_algo);
     add_null_terminator(string_buf, sw_type, sw_type_size);
-    LOG_DBGFMT(" - sw_type     : %s\r\n", string_buf);
-    LOG_DBGFMT(" - measurement :");
+    VERBOSE_UNPRIV_RAW(" - sw_type     : %s\n", string_buf);
+    VERBOSE_UNPRIV_RAW(" - measurement :");
     print_byte_array(measurement_value, measurement_value_size);
-    LOG_DBGFMT(" - locking     : %s\r\n", lock_measurement ? "true" : "false");
+    VERBOSE_UNPRIV_RAW(" - locking     : %s\n", lock_measurement ? "true" : "false");
 }
diff --git a/partitions/scmi/scmi_comms.c b/partitions/scmi/scmi_comms.c
index 796482c..a3075df 100644
--- a/partitions/scmi/scmi_comms.c
+++ b/partitions/scmi/scmi_comms.c
@@ -9,7 +9,7 @@
 #include "scmi_comms.h"
 #include "scmi_hal.h"
 #include "scmi_protocol.h"
-#include "tfm_sp_log.h"
+#include "tfm_log_unpriv.h"
 
 #include <assert.h>
 #include <stddef.h>
@@ -375,9 +375,9 @@
      */
     err = scmi_comms_notification_subscribe(&agent_buf);
     if (err == SCMI_COMMS_SUCCESS) {
-        LOG_INFFMT("SCMI Comms subscribed to power state notifications\r\n");
+        INFO_UNPRIV_RAW("SCMI Comms subscribed to power state notifications\n");
     } else {
-        LOG_ERRFMT("SCMI Comms failed to subscribe to power state notifications\r\n");
+        ERROR_UNPRIV_RAW("SCMI Comms failed to subscribe to power state notifications\n");
     }
 
     while (1) {
diff --git a/partitions/vad_an552_sp/vad_an552_sp_main.c b/partitions/vad_an552_sp/vad_an552_sp_main.c
index eae8f96..4fe7332 100644
--- a/partitions/vad_an552_sp/vad_an552_sp_main.c
+++ b/partitions/vad_an552_sp/vad_an552_sp_main.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021-2022, Arm Limited. All rights reserved.
+ * SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -12,7 +12,7 @@
 #include "vad_an552_defs.h"
 #include "vad_an552.h"
 #include "timeout.h"
-#include "tfm_sp_log.h"
+#include "tfm_log_unpriv.h"
 #include "vad_an552_device_definition.h"
 #include "audio_codec_mps3.h"
 #include "cmsis.h"
@@ -203,7 +203,7 @@
        IRQ is triggered */
     audio_i2s_mps3_set_rx_buff_water_lvl(&MPS3_I2S_DEV_S, 1);
 
-    LOG_DBGFMT("[VAD] Secure partition initialized\r\n");
+    VERBOSE_UNPRIV_RAW("[VAD] Secure partition initialized\n");
 
     while (1) {
         signals = psa_wait(PSA_WAIT_ANY, PSA_BLOCK);