SPM: Clean up SPM log output

Couple of things for cleaning up the SPM log:

* As 'MSGVAL' is customized for 'message + value', append '\r\n' at
  the end to save extra 'MSG("\r\n")' which looks redundant.
  Also adjusted related caller place to provide better adaptation.

* Override the default log level into Debug(3) under debug build.

Change-Id: If4392262fd112494ec86741c1ba5c8f256fd79fe
Signed-off-by: Ken Liu <Ken.Liu@arm.com>
diff --git a/secure_fw/spm/common/spm_log.c b/secure_fw/spm/common/spm_log.c
index dc0e995..b15f87d 100644
--- a/secure_fw/spm/common/spm_log.c
+++ b/secure_fw/spm/common/spm_log.c
@@ -7,7 +7,7 @@
 
 #include "tfm_spm_log.h"
 
-#define MAX_DIGIT_BITS 10  /* Max bits of uint32_t value 0xFFFFFFFF add '0x' */
+#define MAX_DIGIT_BITS 12  /* 8 char for number, 2 for '0x' and 2 for '\r\n' */
 const static char HEX_TABLE[] = {'0', '1', '2', '3', '4', '5', '6', '7',
                                  '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
 
@@ -22,13 +22,15 @@
 
 static void to_hex(uint32_t value, char msg[])
 {
-    int i;
+    int i = MAX_DIGIT_BITS - 1;
 
-    msg[0] = '0';
-    msg[1] = 'x';
-    for (i = MAX_DIGIT_BITS - 1; i >= 2; i--, value >>= 4) {
+    msg[i--] = '\n';
+    msg[i--] = '\r';
+    for (; i > 1; i--, value >>= 4) {
         msg[i] = HEX_TABLE[value & 0xF];
     }
+    msg[i--] = 'x';
+    msg[i--] = '0';
 }
 
 int32_t spm_log_msgval(const char *msg, size_t len, uint32_t value)