Documentation

Documentation

Includes

tuya_cloud_types.h

#include "tuya_cloud_types.h"
#include "tuya_cloud_types.h"

Macros

Marco _UNI_LOG_H

#define _UNI_LOG_H


      

Marco TY_LOG_LEVEL_ERR

#define TY_LOG_LEVEL_ERR      0 // error information
/**
 * @brief Definition of log level
 */

Marco TY_LOG_LEVEL_WARN

#define TY_LOG_LEVEL_WARN     1 // warnning information


      

Marco TY_LOG_LEVEL_NOTICE

#define TY_LOG_LEVEL_NOTICE   2 // notice information


      

Marco TY_LOG_LEVEL_INFO

#define TY_LOG_LEVEL_INFO     3 // information


      

Marco TY_LOG_LEVEL_DEBUG

#define TY_LOG_LEVEL_DEBUG    4 // debug information , should delete in release version


      

Marco TY_LOG_LEVEL_TRACE

#define TY_LOG_LEVEL_TRACE    5 // trace information , should delete in release version


      

Marco TY_DEAULT_LOG_LEVEL

#define TY_DEAULT_LOG_LEVEL   TY_LOG_LEVEL_DEBUG


      

Marco TY_DEAULT_LOG_LEVEL

#define TY_DEAULT_LOG_LEVEL   TY_LOG_LEVEL_INFO


      

Marco DEF_LOG_BUF_LEN

#define DEF_LOG_BUF_LEN	1024


      

Marco LOG_LEVEL_MIN

#define LOG_LEVEL_MIN	0


      

Marco LOG_LEVEL_MAX

#define LOG_LEVEL_MAX	5


      

Marco _THIS_FILE_NAME_

#define _THIS_FILE_NAME_ __FILE__


      

Marco SAK_PRINT_LOG(module,level,fmt, ...)

#define SAK_PRINT_LOG(module,level,fmt, ...) \
do \
{ \
   PrintLog(module,level, \
            _THIS_FILE_NAME_, __LINE__,\
            fmt,##__VA_ARGS__); \
}while(0)


      

Marco TUYA_REDUCE_BIN_LEVEL1

#define TUYA_REDUCE_BIN_LEVEL1 1
// this level, log dont has line_number information 

Marco TUYA_REDUCE_BIN_LEVEL2

#define TUYA_REDUCE_BIN_LEVEL2 2
// this level, log dont has file_name and line_number information

Marco TUYA_REDUCE_BIN_LEVEL3

#define TUYA_REDUCE_BIN_LEVEL3 3
// this level, log dont has file_name , line_number and no tare and debug information

Marco SAK_PRINT_ERR_LOG(fmt, ...)

#define SAK_PRINT_ERR_LOG(fmt, ...) \
do \
{ \
   PrintErrLog(fmt,##__VA_ARGS__); \
}while(0)


      

Marco SAK_PRINT_WARN_LOG(fmt, ...)

#define SAK_PRINT_WARN_LOG(fmt, ...) \
do \
{ \
   PrintWarnLog(fmt,##__VA_ARGS__); \
}while(0)


      

Marco SAK_PRINT_INFO_LOG(fmt, ...)

#define SAK_PRINT_INFO_LOG(fmt, ...) \
do \
{ \
   PrintInfoLog(fmt,##__VA_ARGS__); \
}while(0)


      

Marco SAK_PRINT_NOTICE_LOG(fmt, ...)

#define SAK_PRINT_NOTICE_LOG(fmt, ...) \
do \
{ \
   PrintNoticeLog(fmt,##__VA_ARGS__); \
}while(0)


      

Marco SAK_PRINT_DEBUG_LOG(fmt, ...)

#define SAK_PRINT_DEBUG_LOG(fmt, ...) \
do \
{ \
   PrintDebugLog(fmt,##__VA_ARGS__); \
}while(0)


      

Marco SAK_PRINT_TRACE_LOG(fmt, ...)

#define SAK_PRINT_TRACE_LOG(fmt, ...) \
do \
{ \
   PrintTraceLog(fmt,##__VA_ARGS__); \
}while(0)


      

Marco SAK_PRINT_ERR_LOG(fmt, ...)

#define SAK_PRINT_ERR_LOG(fmt, ...) \
do \
{ \
   PrintErrLog(_THIS_FILE_NAME_, fmt,##__VA_ARGS__); \
}while(0)


      

Marco SAK_PRINT_WARN_LOG(fmt, ...)

#define SAK_PRINT_WARN_LOG(fmt, ...) \
do \
{ \
   PrintWarnLog(_THIS_FILE_NAME_, fmt,##__VA_ARGS__); \
}while(0)


      

Marco SAK_PRINT_INFO_LOG(fmt, ...)

#define SAK_PRINT_INFO_LOG(fmt, ...) \
do \
{ \
   PrintInfoLog(_THIS_FILE_NAME_, fmt,##__VA_ARGS__); \
}while(0)


      

Marco SAK_PRINT_NOTICE_LOG(fmt, ...)

#define SAK_PRINT_NOTICE_LOG(fmt, ...) \
do \
{ \
   PrintNoticeLog(_THIS_FILE_NAME_, fmt,##__VA_ARGS__); \
}while(0)


      

Marco SAK_PRINT_DEBUG_LOG(fmt, ...)

#define SAK_PRINT_DEBUG_LOG(fmt, ...) \
do \
{ \
   PrintDebugLog(_THIS_FILE_NAME_, fmt,##__VA_ARGS__); \
}while(0)


      

Marco SAK_PRINT_TRACE_LOG(fmt, ...)

#define SAK_PRINT_TRACE_LOG(fmt, ...) \
do \
{ \
   PrintTraceLog(_THIS_FILE_NAME_, fmt,##__VA_ARGS__); \
}while(0)


      

Marco SAK_PRINT_ERR_LOG(fmt, ...)

#define SAK_PRINT_ERR_LOG(fmt, ...) \
do \
{ \
   PrintErrLog(_THIS_FILE_NAME_, __LINE__, fmt,##__VA_ARGS__); \
}while(0)


      

Marco SAK_PRINT_WARN_LOG(fmt, ...)

#define SAK_PRINT_WARN_LOG(fmt, ...) \
do \
{ \
   PrintWarnLog(_THIS_FILE_NAME_, __LINE__,fmt,##__VA_ARGS__); \
}while(0)


      

Marco SAK_PRINT_INFO_LOG(fmt, ...)

#define SAK_PRINT_INFO_LOG(fmt, ...) \
do \
{ \
   PrintInfoLog(_THIS_FILE_NAME_, __LINE__,fmt,##__VA_ARGS__); \
}while(0)


      

Marco SAK_PRINT_NOTICE_LOG(fmt, ...)

#define SAK_PRINT_NOTICE_LOG(fmt, ...) \
do \
{ \
   PrintNoticeLog(_THIS_FILE_NAME_, __LINE__,fmt,##__VA_ARGS__); \
}while(0)


      

Marco SAK_PRINT_DEBUG_LOG(fmt, ...)

#define SAK_PRINT_DEBUG_LOG(fmt, ...) \
do \
{ \
   PrintDebugLog(_THIS_FILE_NAME_, __LINE__,fmt,##__VA_ARGS__); \
}while(0)


      

Marco SAK_PRINT_TRACE_LOG(fmt, ...)

#define SAK_PRINT_TRACE_LOG(fmt, ...) \
do \
{ \
   PrintTraceLog(_THIS_FILE_NAME_, __LINE__,fmt,##__VA_ARGS__); \
}while(0)


      

Marco PR_TRACE(fmt, ...)

#define PR_TRACE(fmt, ...) 


      

Marco PR_TRACE_ENTER()

#define PR_TRACE_ENTER() 


      

Marco PR_TRACE_LEAVE

#define PR_TRACE_LEAVE()


      

Marco MPR_TRACE(module,fmt, ...)

#define MPR_TRACE(module,fmt, ...) 


      

Marco PR_DEBUG(fmt, ...)

#define PR_DEBUG(fmt, ...) 


      

Marco MPR_DEBUG(module,fmt, ...)

#define MPR_DEBUG(module,fmt, ...) 


      

Marco PR_TRACE(fmt, ...)

#define PR_TRACE(fmt, ...)  SAK_PRINT_TRACE_LOG(fmt, ##__VA_ARGS__)


      

Marco PR_TRACE_ENTER()

#define PR_TRACE_ENTER()    PR_TRACE("enter [%s]", (const char*)__func__)


      

Marco PR_TRACE_LEAVE()

#define PR_TRACE_LEAVE()    PR_TRACE("leave [%s]", (const char*)__func__)


      

Marco MPR_TRACE(module,fmt, ...)

#define MPR_TRACE(module,fmt, ...) SAK_PRINT_LOG(module,TY_LOG_LEVEL_TRACE, fmt, ##__VA_ARGS__)


      

Marco PR_DEBUG(fmt, ...)

#define PR_DEBUG(fmt, ...)        SAK_PRINT_DEBUG_LOG(fmt, ##__VA_ARGS__)


      

Marco MPR_DEBUG(module,fmt, ...)

#define MPR_DEBUG(module,fmt, ...) SAK_PRINT_LOG(module,TY_LOG_LEVEL_DEBUG, fmt, ##__VA_ARGS__)


      

Marco PR_ERR(fmt, ...)

#define PR_ERR(fmt, ...) SAK_PRINT_ERR_LOG(fmt, ##__VA_ARGS__)
// log interface for user

Marco PR_WARN(fmt, ...)

#define PR_WARN(fmt, ...) SAK_PRINT_WARN_LOG(fmt, ##__VA_ARGS__)


      

Marco PR_NOTICE(fmt, ...)

#define PR_NOTICE(fmt, ...) SAK_PRINT_NOTICE_LOG(fmt, ##__VA_ARGS__)


      

Marco PR_INFO(fmt, ...)

#define PR_INFO(fmt, ...) SAK_PRINT_INFO_LOG(fmt, ##__VA_ARGS__)


      

Marco SET_PR_DEBUG_LEVEL(level)

#define SET_PR_DEBUG_LEVEL(level) SetLogManageAttr(level)
// set log level

Marco MPR_ERR(module,fmt, ...)

#define MPR_ERR(module,fmt, ...) SAK_PRINT_LOG(module,TY_LOG_LEVEL_ERR, fmt, ##__VA_ARGS__)
// log output interface with module name

Marco MPR_WARN(module,fmt, ...)

#define MPR_WARN(module,fmt, ...) SAK_PRINT_LOG(module,TY_LOG_LEVEL_WARN, fmt, ##__VA_ARGS__)


      

Marco MPR_NOTICE(module,fmt, ...)

#define MPR_NOTICE(module,fmt, ...) SAK_PRINT_LOG(module,TY_LOG_LEVEL_NOTICE, fmt, ##__VA_ARGS__)


      

Marco MPR_INFO(module,fmt, ...)

#define MPR_INFO(module,fmt, ...) SAK_PRINT_LOG(module,TY_LOG_LEVEL_INFO, fmt, ##__VA_ARGS__)


      

Marco PR_DEBUG_RAW

#define PR_DEBUG_RAW(fmt, ...)


      

Marco PR_DEBUG_RAW(fmt, ...)

#define PR_DEBUG_RAW(fmt, ...) PrintLogRaw(fmt, ##__VA_ARGS__)


      

Marco PR_DEBUG_RAW

#define PR_DEBUG_RAW(fmt, ...)

      

Functions

Func PrintLog

int PrintLog(const char* pModuleName,
                const LOG_LEVEL logLevel,
                const char* pFile, const int line,
                const char* pFmt,...);
/**
 * @brief output log
 *
 * @param[in] pModuleName, module name
 * @param[in] logLevel, this log level
 * @param[in] pFile, file name of this log
 * @param[in] line, line number in the file of this log
 * @param[in] pFmt, format string
 * @param[in] ..., parameters
 *
 * @note This API is used for output log.
 *
 * @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
 */

Func PrintErrLog

int PrintErrLog(const char* pFmt,...);


      

Func PrintWarnLog

int PrintWarnLog(const char* pFmt,...);


      

Func PrintInfoLog

int PrintInfoLog(const char* pFmt,...);


      

Func PrintNoticeLog

int PrintNoticeLog(const char* pFmt,...);


      

Func PrintDebugLog

int PrintDebugLog(const char* pFmt,...);


      

Func PrintTraceLog

int PrintTraceLog(const char* pFmt,...);


      

Func PrintErrLog

int PrintErrLog(const char* pFile, const char* pFmt,...);


      

Func PrintWarnLog

int PrintWarnLog(const char* pFile, const char* pFmt,...);


      

Func PrintInfoLog

int PrintInfoLog(const char* pFile, const char* pFmt,...);


      

Func PrintNoticeLog

int PrintNoticeLog(const char* pFile, const char* pFmt,...);


      

Func PrintDebugLog

int PrintDebugLog(const char* pFile, const char* pFmt,...);


      

Func PrintTraceLog

int PrintTraceLog(const char* pFile, const char* pFmt,...);


      

Func PrintErrLog

int PrintErrLog(const char* pFile, const int line, const char* pFmt,...);


      

Func PrintWarnLog

int PrintWarnLog(const char* pFile, const int line, const char* pFmt,...);


      

Func PrintInfoLog

int PrintInfoLog(const char* pFile, const int line, const char* pFmt,...);


      

Func PrintNoticeLog

int PrintNoticeLog(const char* pFile, const int line, const char* pFmt,...);


      

Func PrintDebugLog

int PrintDebugLog(const char* pFile, const int line, const char* pFmt,...);


      

Func PrintTraceLog

int PrintTraceLog(const char* pFile, const int line, const char* pFmt,...);


      

Func CreateLogManageAndInit

OPERATE_RET CreateLogManageAndInit(IN CONST LOG_LEVEL curLogLevel,IN CONST INT_T buf_len,\
                                             IN CONST LOG_OUTPUT output);
/**
 * @brief initialize log management.
 *
 * @param[in] curLogLevel , set log level
 * @param[in] buf_len , set log buffer size
 * @param[in] output , log print function pointer
 *
 * @note This API is used for initializing log management.
 *
 * @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
 */

Func AddOutputTerm

OPERATE_RET AddOutputTerm(IN CONST CHAR_T *name,IN CONST LOG_OUTPUT term);
/**
 * @brief add one output terminal.
 *
 * @param[in] name , terminal name
 * @param[in] term , output function pointer
 *
 * @note This API is used for adding one output terminal.
 *
 * @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
 */

Func DelOutputTerm

VOID DelOutputTerm(IN CONST CHAR_T *name);
/**
 * @brief delete one output terminal.
 *
 * @param[in] name , terminal name
 *
 * @note This API is used for delete one output terminal.
 *
 * @return NONE
 */

Func SetLogManageAttr

OPERATE_RET SetLogManageAttr(IN CONST LOG_LEVEL curLogLevel);
/**
 * @brief set global log level.
 *
 * @param[in] curLogLevel , log level
 *
 * @note This API is used for setting global log level.
 *
 * @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
 */

Func SetLogManagemtime

OPERATE_RET SetLogManagemtime(BOOL_T if_ms_level);
/**
 * @brief set log time whether show in millisecond.
 *
 * @param[in] if_ms_level, whether log time include millisecond
 *
 * @note This API is used for setting log time whether include milisecond.
 *
 * @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
 */

Func GetLogManageAttr

OPERATE_RET GetLogManageAttr(OUT LOG_LEVEL *pCurLogLevel);
/**
 * @brief get global log level.
 *
 * @param[in] pCurLogLevel, global log level
 *
 * @note This API is used for getting global log level.
 *
 * @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
 */

Func AddModuleLevel

OPERATE_RET AddModuleLevel(IN CONST PCHAR_T pModuleName,\
                                 IN CONST LOG_LEVEL logLevel);
/**
 * @brief add one module's log level
 *
 * @param[in] pModuleName, module name
 * @param[in] logLevel, this module's log level
 *
 * @note This API is used for adding one module's log level.
 *
 * @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
 */

Func SetModuleLevel

OPERATE_RET SetModuleLevel(IN CONST PCHAR_T pModuleName,\
                                 LOG_LEVEL log_level);
/**
 * @brief add one module's log level
 *
 * @param[in] pModuleName, module name
 * @param[in] logLevel, this module's log level
 *
 * @note This API is used for adding one module's log level.
 *
 * @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
 */

Func GetModuleLevel

OPERATE_RET GetModuleLevel(IN CONST PCHAR_T pModuleName,\
                                 OUT LOG_LEVEL *pLogLevel);
/**
 * @brief get one module's log level
 *
 * @param[in] pModuleName, module name
 * @param[in] logLevel, this module's log level
 *
 * @note This API is used for getting one module's log level.
 *
 * @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
 */

Func DeleteModuleLevel

OPERATE_RET DeleteModuleLevel(IN CONST PCHAR_T pModuleName);
/**
 * @brief delete one module's log level
 *
 * @param[in] pModuleName, module name
 *
 * @note This API is used for deleting one module's log level.
 *
 * @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
 */

Func PrintLogRaw

OPERATE_RET PrintLogRaw(IN CONST PCHAR_T pFmt,...);
/**
 * @brief only print user log information
 *
 * @param[in] pFmt, format string
 * @param[in] ..., parameter
 *
 * @note This API is used for print only user log info.
 *
 * @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
 */

Func ReleaseLogManage

VOID ReleaseLogManage(VOID);
/**
 * @brief destroy log management
 *
 * @param[in] pFmt, format string
 * @param[in] ..., parameter
 *
 * @note This API is used for destroy log management.
 *
 * @return NONE
 */

Func tuya_debug_hex_dump

VOID tuya_debug_hex_dump(CHAR_T *title, UINT8_T width, UINT8_T *buf, UINT16_T size);
/**
 * @brief print a buffer in hex format
 *
 * @param[in] title, buffer title for print
 * @param[in] width, one line width
 * @param[in] buf, buffer address
 * @param[in] size, buffer size
 *
 * @note This API is used for print one buffer.
 *
 * @return NONE
 */

Vars

Consts

Types

Typedefs

Typedef LOG_LEVEL

typedef INT_T LOG_LEVEL;


      

Typedef LOG_OUTPUT

typedef VOID (*LOG_OUTPUT)(IN CONST     CHAR_T *str);
// prototype of log output function