Skip to content

Commit d8ca1e4

Browse files
committed
update tuya_cloud_service
1 parent cff9c18 commit d8ca1e4

3 files changed

Lines changed: 71 additions & 60 deletions

File tree

src/libhttp/coreHTTP/source/core_http_client.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1462,7 +1462,7 @@ static HTTPStatus_t addHeader( HTTPRequestHeaders_t * pRequestHeaders,
14621462
pRequestHeaders->headersLen = totalRequiredLen;
14631463
}
14641464
}
1465-
else if( returnStatus == HTTPSuccess )
1465+
else
14661466
{
14671467
LogError( ( "Unable to add header in buffer: "
14681468
"Buffer has insufficient memory: "

src/tal_system/include/tal_log.h

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -87,41 +87,41 @@ typedef TAL_LOG_LEVEL_E LOG_LEVEL;
8787
#define DEF_LOG_BUF_LEN 4096
8888
#endif
8989

90-
#ifdef ENABLE_PRINTF_CHECK
91-
#define PRINTF_CHECK(formatArg, firstVarArg) __attribute__((format(printf, formatArg, firstVarArg)))
92-
#else
93-
#define PRINTF_CHECK(...)
94-
#endif
95-
96-
#if defined(__GNUC__) || defined(__clang__)
97-
#define LOG_FMT_IS_CONST(fmt) __builtin_constant_p(fmt)
98-
#else
99-
#define LOG_FMT_IS_CONST(fmt) (FALSE)
100-
#endif
101-
102-
PRINTF_CHECK(4, 5)
103-
OPERATE_RET tal_log_print(const TAL_LOG_LEVEL_E level, const char *file, const int line, const char *fmt, ...);
104-
PRINTF_CHECK(5, 6)
105-
OPERATE_RET tal_log_print_secure(BOOL_T is_const_fmt, const TAL_LOG_LEVEL_E level, const char *file, const int line,
106-
const char *fmt, ...);
107-
108-
// file name maybe define from complie parameter
109-
#ifndef _THIS_FILE_NAME_
110-
#define _THIS_FILE_NAME_ __FILE__
111-
#endif
112-
113-
#define PR_ERR(fmt, ...) \
114-
tal_log_print_secure(LOG_FMT_IS_CONST(fmt), TAL_LOG_LEVEL_ERR, _THIS_FILE_NAME_, __LINE__, fmt, ##__VA_ARGS__)
115-
#define PR_WARN(fmt, ...) \
116-
tal_log_print_secure(LOG_FMT_IS_CONST(fmt), TAL_LOG_LEVEL_WARN, _THIS_FILE_NAME_, __LINE__, fmt, ##__VA_ARGS__)
117-
#define PR_NOTICE(fmt, ...) \
118-
tal_log_print_secure(LOG_FMT_IS_CONST(fmt), TAL_LOG_LEVEL_NOTICE, _THIS_FILE_NAME_, __LINE__, fmt, ##__VA_ARGS__)
119-
#define PR_INFO(fmt, ...) \
120-
tal_log_print_secure(LOG_FMT_IS_CONST(fmt), TAL_LOG_LEVEL_INFO, _THIS_FILE_NAME_, __LINE__, fmt, ##__VA_ARGS__)
121-
#define PR_DEBUG(fmt, ...) \
122-
tal_log_print_secure(LOG_FMT_IS_CONST(fmt), TAL_LOG_LEVEL_DEBUG, _THIS_FILE_NAME_, __LINE__, fmt, ##__VA_ARGS__)
123-
#define PR_TRACE(fmt, ...) \
124-
tal_log_print_secure(LOG_FMT_IS_CONST(fmt), TAL_LOG_LEVEL_TRACE, _THIS_FILE_NAME_, __LINE__, fmt, ##__VA_ARGS__)
90+
#ifdef ENABLE_PRINTF_CHECK
91+
#define PRINTF_CHECK(formatArg, firstVarArg) __attribute__((format(printf, formatArg, firstVarArg)))
92+
#else
93+
#define PRINTF_CHECK(...)
94+
#endif
95+
96+
#if defined(__GNUC__) || defined(__clang__)
97+
#define LOG_FMT_IS_CONST(fmt) __builtin_constant_p(fmt)
98+
#else
99+
#define LOG_FMT_IS_CONST(fmt) (FALSE)
100+
#endif
101+
102+
PRINTF_CHECK(4, 5)
103+
OPERATE_RET tal_log_print(const TAL_LOG_LEVEL_E level, const char *file, const int line, const char *fmt, ...);
104+
PRINTF_CHECK(5, 6)
105+
OPERATE_RET tal_log_print_secure(BOOL_T is_const_fmt, const TAL_LOG_LEVEL_E level, const char *file, const int line,
106+
const char *fmt, ...);
107+
108+
// file name maybe define from complie parameter
109+
#ifndef _THIS_FILE_NAME_
110+
#define _THIS_FILE_NAME_ __FILE__
111+
#endif
112+
113+
#define PR_ERR(fmt, ...) \
114+
tal_log_print_secure(LOG_FMT_IS_CONST(fmt), TAL_LOG_LEVEL_ERR, _THIS_FILE_NAME_, __LINE__, fmt, ##__VA_ARGS__)
115+
#define PR_WARN(fmt, ...) \
116+
tal_log_print_secure(LOG_FMT_IS_CONST(fmt), TAL_LOG_LEVEL_WARN, _THIS_FILE_NAME_, __LINE__, fmt, ##__VA_ARGS__)
117+
#define PR_NOTICE(fmt, ...) \
118+
tal_log_print_secure(LOG_FMT_IS_CONST(fmt), TAL_LOG_LEVEL_NOTICE, _THIS_FILE_NAME_, __LINE__, fmt, ##__VA_ARGS__)
119+
#define PR_INFO(fmt, ...) \
120+
tal_log_print_secure(LOG_FMT_IS_CONST(fmt), TAL_LOG_LEVEL_INFO, _THIS_FILE_NAME_, __LINE__, fmt, ##__VA_ARGS__)
121+
#define PR_DEBUG(fmt, ...) \
122+
tal_log_print_secure(LOG_FMT_IS_CONST(fmt), TAL_LOG_LEVEL_DEBUG, _THIS_FILE_NAME_, __LINE__, fmt, ##__VA_ARGS__)
123+
#define PR_TRACE(fmt, ...) \
124+
tal_log_print_secure(LOG_FMT_IS_CONST(fmt), TAL_LOG_LEVEL_TRACE, _THIS_FILE_NAME_, __LINE__, fmt, ##__VA_ARGS__)
125125

126126
#define PR_HEXDUMP_ERR(title, buf, size) \
127127
tal_log_hex_dump(TAL_LOG_LEVEL_ERR, _THIS_FILE_NAME_, __LINE__, title, 8, buf, size)
@@ -286,30 +286,30 @@ PRINTF_CHECK(1, 2)
286286
* @param[in] pFmt: format string
287287
* @param[in] ...: parameter
288288
*
289-
* @return OPRT_OK on success. Others on error, please refer to
290-
* tuya_error_code.h
291-
*/
292-
OPERATE_RET tal_log_print_raw(const char *pFmt, ...);
293-
294-
/**
295-
* @brief Print user提供的字符串,内部自动将'%'转义为'%%'以避免格式化解析。
296-
*
297-
* @param[in] level log level
298-
* @param[in] file file name
299-
* @param[in] line line number
300-
* @param[in] prefix 固定前缀,可为NULL或空串
301-
* @param[in] user_str 需要输出的用户字符串
302-
*
303-
* @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
304-
*/
305-
OPERATE_RET tal_log_print_escape(const TAL_LOG_LEVEL_E level, const char *file, const int line, const char *prefix,
306-
const char *user_str);
307-
308-
/**
309-
* @brief destroy log management
310-
*
311-
* @param[in] pFmt, format string
312-
* @param[in] ..., parameter
289+
* @return OPRT_OK on success. Others on error, please refer to
290+
* tuya_error_code.h
291+
*/
292+
OPERATE_RET tal_log_print_raw(const char *pFmt, ...);
293+
294+
//**
295+
* @brief Print the user-provided string, internally escaping '%' to '%%' to avoid format parsing.
296+
*
297+
* @param[in] level log level
298+
* @param[in] file file name
299+
* @param[in] line line number
300+
* @param[in] prefix fixed prefix, can be NULL or empty string
301+
* @param[in] user_str user string to be output
302+
*
303+
* @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
304+
*/
305+
OPERATE_RET tal_log_print_escape(const TAL_LOG_LEVEL_E level, const char *file, const int line, const char *prefix,
306+
const char *user_str);
307+
308+
/**
309+
* @brief destroy log management
310+
*
311+
* @param[in] pFmt, format string
312+
* @param[in] ..., parameter
313313
*
314314
* @note This API is used for destroy log management.
315315
*

src/tal_system/src/tal_log.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,17 @@ OPERATE_RET tal_log_print_raw(const char *pFmt, ...)
635635
return opRet;
636636
}
637637

638+
/**
639+
* @brief Print the user-provided string, internally escaping '%' to '%%' to avoid format parsing.
640+
*
641+
* @param[in] level log level
642+
* @param[in] file file name
643+
* @param[in] line line number
644+
* @param[in] prefix fixed prefix, can be NULL or empty string
645+
* @param[in] user_str user string to be output
646+
*
647+
* @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
648+
*/
638649
OPERATE_RET tal_log_print_escape(const TAL_LOG_LEVEL_E level, const char *file, const int line, const char *prefix,
639650
const char *user_str)
640651
{

0 commit comments

Comments
 (0)