]> granicus.if.org Git - esp-idf/commitdiff
components/openssl: add more debug stream output function
authorDong Heng <dongheng@espressif.com>
Tue, 1 Nov 2016 07:16:14 +0000 (15:16 +0800)
committerDong Heng <dongheng@espressif.com>
Tue, 1 Nov 2016 07:16:14 +0000 (15:16 +0800)
components/openssl/include/internal/ssl_dbg.h
components/openssl/include/platform/ssl_port.h
components/openssl/platform/ssl_pm.c

index 5b909955e4c279f90b8dda5ddf2249143ef74d54..887fe2e82b3ca126b329becc246a8669925d542c 100644 (file)
 #endif
 
 #if SSL_DEBUG_ENBALE
-    #ifndef SSL_PRINT
+    #if !defined(SSL_PRINT_LOG) || !defined(SSL_ERROR_LOG) || !defined(SSL_LOCAL_LOG)
         #include "stdio.h"
         extern int printf(const char *fmt, ...);
-        #define SSL_PRINT printf
+        #ifndef SSL_PRINT_LOG
+            #define SSL_PRINT_LOG printf
+        #endif
+        #ifndef SSL_ERROR_LOG
+            #define SSL_ERROR_LOG printf
+        #endif 
+        #ifndef SSL_LOCAL_LOG
+            #define SSL_LOCAL_LOG printf
+        #endif
     #endif
 #else
-    #ifdef SSL_PRINT
-        #undef SSL_PRINT
-        #define SSL_PRINT(...)
+    #ifdef SSL_PRINT_LOG
+        #undef SSL_PRINT_LOG
+        #define SSL_PRINT_LOG(...)
+    #endif
+    #ifdef SSL_ERROR_LOG
+        #undef SSL_ERROR_LOG
+        #define SSL_ERROR_LOG(...)
+    #endif
+    #ifdef SSL_LOCAL_LOG
+        #undef SSL_LOCAL_LOG
+        #define SSL_LOCAL_LOG(...)
     #endif
 #endif
 
 #if SSL_DEBUG_LOCATION_ENABLE
-    #define SSL_DEBUG_LOCATION() SSL_PRINT("%s %s line %d\n", __FILE__, __FUNCTION__, __LINE__)
+    #define SSL_DEBUG_LOCATION() SSL_LOCAL_LOG("%s %s line %d\n", __FILE__, __FUNCTION__, __LINE__)
 #else
     #define SSL_DEBUG_LOCATION()
 #endif
     #define SSL_ASSERT(s)
 #endif
 
-#define SSL_ERR(err, go, fmt, ...) { SSL_DEBUG_LOCATION(); SSL_PRINT(fmt, ##__VA_ARGS__); ret = err; goto go; }
+#define SSL_ERR(err, go, fmt, ...) { SSL_DEBUG_LOCATION(); SSL_ERROR_LOG(fmt, ##__VA_ARGS__); ret = err; goto go; }
 
-#define SSL_RET(go, fmt, ...) {  SSL_DEBUG_LOCATION(); SSL_PRINT(fmt, ##__VA_ARGS__); goto go; }
+#define SSL_RET(go, fmt, ...) {  SSL_DEBUG_LOCATION(); SSL_ERROR_LOG(fmt, ##__VA_ARGS__); goto go; }
 
-#define SSL_DEBUG(level, fmt, ...) { if (level > SSL_DEBUG_LEVEL) {SSL_PRINT(fmt, ##__VA_ARGS__);} }
+#define SSL_DEBUG(level, fmt, ...) { if (level > SSL_DEBUG_LEVEL) {SSL_PRINT_LOG(fmt, ##__VA_ARGS__);} }
 
 #ifdef __cplusplus
 }
index 1e4c2f31f97b3aea1937fa688f68d0804ee20bc9..35c8dc18f9d8c74a07cb8faee0719456f43ae300 100644 (file)
@@ -36,7 +36,9 @@ size_t ssl_strlen(const char *src);
 void ssl_speed_up_enter(void);
 void ssl_speed_up_exit(void);
 
-#define SSL_PRINT(fmt, ...) ESP_LOGD("OpenSSL", fmt, ##__VA_ARGS__)
+#define SSL_PRINT_LOG(fmt, ...) ESP_LOGD("openssl", fmt, ##__VA_ARGS__)
+#define SSL_ERROR_LOG(fmt, ...) ESP_LOGE("openssl", fmt, ##__VA_ARGS__)
+#define SSL_LOCAL_LOG(fmt, ...) ESP_LOGD("openssl", fmt, ##__VA_ARGS__)
 
 #elif defined(SSL_PLATFORM_USER_INCLUDE)
 
index 21c0ac58c930a4c2a60c7e973100ef190fe308ea..92e72bfdb8df96ed5eafa3c8d3bd2ae9711ae524 100644 (file)
@@ -410,7 +410,7 @@ int x509_pm_show_info(X509 *x)
 
     ssl_mem_free(buf);
 
-    SSL_PRINT("%s", buf);
+    SSL_DEBUG(1, "%s", buf);
 
     return 0;