components/openssl: add more debug stream output function

This commit is contained in:
Dong Heng 2016-11-01 15:16:14 +08:00
parent bc710e5b88
commit 12e78e9590
3 changed files with 29 additions and 11 deletions

View file

@ -39,20 +39,36 @@
#endif #endif
#if SSL_DEBUG_ENBALE #if SSL_DEBUG_ENBALE
#ifndef SSL_PRINT #if !defined(SSL_PRINT_LOG) || !defined(SSL_ERROR_LOG) || !defined(SSL_LOCAL_LOG)
#include "stdio.h" #include "stdio.h"
extern int printf(const char *fmt, ...); 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 #endif
#else #else
#ifdef SSL_PRINT #ifdef SSL_PRINT_LOG
#undef SSL_PRINT #undef SSL_PRINT_LOG
#define SSL_PRINT(...) #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
#endif #endif
#if SSL_DEBUG_LOCATION_ENABLE #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 #else
#define SSL_DEBUG_LOCATION() #define SSL_DEBUG_LOCATION()
#endif #endif
@ -63,11 +79,11 @@
#define SSL_ASSERT(s) #define SSL_ASSERT(s)
#endif #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 #ifdef __cplusplus
} }

View file

@ -36,7 +36,9 @@ size_t ssl_strlen(const char *src);
void ssl_speed_up_enter(void); void ssl_speed_up_enter(void);
void ssl_speed_up_exit(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) #elif defined(SSL_PLATFORM_USER_INCLUDE)

View file

@ -410,7 +410,7 @@ int x509_pm_show_info(X509 *x)
ssl_mem_free(buf); ssl_mem_free(buf);
SSL_PRINT("%s", buf); SSL_DEBUG(1, "%s", buf);
return 0; return 0;