mqtt client release v1.1.0 ...
This commit is contained in:
@@ -10,113 +10,103 @@ int salof_init(void);
|
||||
void salof(const char *fmt, ...);
|
||||
|
||||
/** font color */
|
||||
#define FC_BLACK 30
|
||||
#define FC_RED 31
|
||||
#define FC_GREEN 32
|
||||
#define FC_YELLOW 33
|
||||
#define FC_BLUE 34
|
||||
#define FC_PURPLE 35
|
||||
#define FC_DARK 36
|
||||
#define FC_WHITE 37
|
||||
#define SALOF_FC_BLACK 30
|
||||
#define SALOF_FC_RED 31
|
||||
#define SALOF_FC_GREEN 32
|
||||
#define SALOF_FC_YELLOW 33
|
||||
#define SALOF_FC_BLUE 34
|
||||
#define SALOF_FC_PURPLE 35
|
||||
#define SALOF_FC_DARK 36
|
||||
#define SALOF_FC_WHITE 37
|
||||
|
||||
#ifdef USE_LOG
|
||||
#ifdef SALOF_USING_LOG
|
||||
|
||||
#if USE_SALOF
|
||||
#define PRINT_LOG salof
|
||||
#if SALOF_USING_SALOF
|
||||
#define SALOF_PRINT_LOG salof
|
||||
#else
|
||||
|
||||
#if ((!USE_SALOF)&&(!PRINT_LOG))
|
||||
#define PRINT_LOG printf
|
||||
#if ((!SALOF_USING_SALOF)&&(!SALOF_PRINT_LOG))
|
||||
#define SALOF_PRINT_LOG printf
|
||||
#endif
|
||||
|
||||
#ifndef PRINT_LOG
|
||||
#error "If the USE_LOG macro definition is turned on, you must define PRINT_LOG as the LOG output, such as #definePRINT_LOG printf"
|
||||
#ifndef SALOF_PRINT_LOG
|
||||
#error "If the SALOF_USING_LOG macro definition is turned on, you must define SALOF_PRINT_LOG as the LOG output, such as #definePRINT_LOG printf"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if LOG_COLOR
|
||||
#define LOG_START(l, c) PRINT_LOG("\033\n["#c"m["#l"] >> ")
|
||||
#define LOG_END PRINT_LOG("\033[0m")
|
||||
#if SALOF_LOG_COLOR
|
||||
#define SALOF_LOG_START(l, c) SALOF_PRINT_LOG("\033\n["#c"m["#l"] >> ")
|
||||
#define SALOF_LOG_END SALOF_PRINT_LOG("\033[0m")
|
||||
#else
|
||||
#define LOG_START(l, c) PRINT_LOG("\n["#l"] >> ")
|
||||
#define LOG_END
|
||||
#define SALOF_LOG_START(l, c) SALOF_PRINT_LOG("\n["#l"] >> ")
|
||||
#define SALOF_LOG_END
|
||||
#endif
|
||||
|
||||
#if LOG_TS && LOG_TAR
|
||||
#define LOG_T PRINT_LOG("[TS: %d] [TAR: %s] ",salof_get_tick(), salof_get_task_name())
|
||||
#elif LOG_TS
|
||||
#define LOG_T PRINT_LOG("[TS: %d] ", salof_get_tick())
|
||||
#elif LOG_TAR
|
||||
#define LOG_T PRINT_LOG("[TAR: %s] ", salof_get_task_name())
|
||||
#if SALOF_LOG_TS && SALOF_LOG_TAR
|
||||
#define SALOF_LOG_T SALOF_PRINT_LOG("[TS: %d] [TAR: %s] ",salof_get_tick(), salof_get_task_name())
|
||||
#elif SALOF_LOG_TS
|
||||
#define SALOF_LOG_T SALOF_PRINT_LOG("[TS: %d] ", salof_get_tick())
|
||||
#elif SALOF_LOG_TAR
|
||||
#define SALOF_LOG_T SALOF_PRINT_LOG("[TAR: %s] ", salof_get_task_name())
|
||||
#else
|
||||
#define LOG_T
|
||||
#define SALOF_LOG_T
|
||||
#endif
|
||||
|
||||
|
||||
#define LOG_LINE(l, c, fmt, ...) \
|
||||
#define SALOF_LOG_LINE(l, c, fmt, ...) \
|
||||
do { \
|
||||
LOG_START(l, c); \
|
||||
LOG_T; \
|
||||
PRINT_LOG(fmt, ##__VA_ARGS__); \
|
||||
LOG_END; \
|
||||
SALOF_LOG_START(l, c); \
|
||||
SALOF_LOG_T; \
|
||||
SALOF_PRINT_LOG(fmt, ##__VA_ARGS__); \
|
||||
SALOF_LOG_END; \
|
||||
} while (0)
|
||||
|
||||
#define BASE_LEVEL (0)
|
||||
#define ASSERT_LEVEL (BASE_LEVEL + 1)
|
||||
#define ERR_LEVEL (ASSERT_LEVEL + 1)
|
||||
#define WARN_LEVEL (ERR_LEVEL + 1)
|
||||
#define INFO_LEVEL (WARN_LEVEL + 1)
|
||||
#define DEBUG_LEVEL (INFO_LEVEL + 1)
|
||||
#define SALOF_BASE_LEVEL (0)
|
||||
#define SALOF_ERR_LEVEL (SALOF_BASE_LEVEL + 1)
|
||||
#define SALOF_WARN_LEVEL (SALOF_ERR_LEVEL + 1)
|
||||
#define SALOF_INFO_LEVEL (SALOF_WARN_LEVEL + 1)
|
||||
#define SALOF_DEBUG_LEVEL (SALOF_INFO_LEVEL + 1)
|
||||
|
||||
#ifndef LOG_LEVEL
|
||||
#define LOG_LEVEL DEBUG_LEVEL
|
||||
#ifndef SALOF_LOG_LEVEL
|
||||
#define SALOF_LOG_LEVEL SALOF_DEBUG_LEVEL
|
||||
#endif
|
||||
|
||||
#if LOG_LEVEL < DEBUG_LEVEL
|
||||
#define LOG_DEBUG(fmt, ...)
|
||||
#if SALOF_LOG_LEVEL < SALOF_DEBUG_LEVEL
|
||||
#define SALOF_LOG_DEBUG(fmt, ...)
|
||||
#else
|
||||
#define LOG_DEBUG(fmt, ...) LOG_LINE(D, 0, fmt, ##__VA_ARGS__)
|
||||
#define SALOF_LOG_DEBUG(fmt, ...) SALOF_LOG_LINE(D, 0, fmt, ##__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#if LOG_LEVEL < INFO_LEVEL
|
||||
#define LOG_INFO(fmt, ...)
|
||||
#if SALOF_LOG_LEVEL < SALOF_INFO_LEVEL
|
||||
#define SALOF_LOG_INFO(fmt, ...)
|
||||
#else
|
||||
#define LOG_INFO(fmt, ...) LOG_LINE(I, FC_GREEN, fmt, ##__VA_ARGS__)
|
||||
#define SALOF_LOG_INFO(fmt, ...) SALOF_LOG_LINE(I, SALOF_FC_GREEN, fmt, ##__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#if LOG_LEVEL < WARN_LEVEL
|
||||
#define LOG_WARN(fmt, ...)
|
||||
#if SALOF_LOG_LEVEL < SALOF_WARN_LEVEL
|
||||
#define SALOF_LOG_WARN(fmt, ...)
|
||||
#else
|
||||
#define LOG_WARN(fmt, ...) LOG_LINE(W, FC_YELLOW, fmt, ##__VA_ARGS__)
|
||||
#define SALOF_LOG_WARN(fmt, ...) SALOF_LOG_LINE(W, SALOF_FC_YELLOW, fmt, ##__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#if LOG_LEVEL < ERR_LEVEL
|
||||
#define LOG_ERR(fmt, ...)
|
||||
#if SALOF_LOG_LEVEL < SALOF_ERR_LEVEL
|
||||
#define SALOF_LOG_ERR(fmt, ...)
|
||||
#else
|
||||
#define LOG_ERR(fmt, ...) LOG_LINE(E, FC_RED, fmt, ##__VA_ARGS__)
|
||||
#define SALOF_LOG_ERR(fmt, ...) SALOF_LOG_LINE(E, SALOF_FC_RED, fmt, ##__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#if LOG_LEVEL < ASSERT_LEVEL
|
||||
#define LOG_ASSERT(fmt, ...)
|
||||
#define ASSERT(x)
|
||||
#if SALOF_LOG_LEVEL < SALOF_BASE_LEVEL
|
||||
#define SALOF_LOG(fmt, ...)
|
||||
#else
|
||||
#define LOG_ASSERT(fmt, ...) LOG_LINE(A, FC_RED, fmt, ##__VA_ARGS__)
|
||||
#define ASSERT(x) if((x)==0) LOG_ASSERT("%s, %d\n",__FILE__,__LINE__)
|
||||
#endif
|
||||
|
||||
#if LOG_LEVEL < BASE_LEVEL
|
||||
#define LOG(fmt, ...)
|
||||
#else
|
||||
#define LOG(fmt, ...) PRINT_LOG(fmt, ##__VA_ARGS__)
|
||||
#define SALOF_LOG(fmt, ...) SALOF_PRINT_LOG(fmt, ##__VA_ARGS__)
|
||||
#endif
|
||||
#else
|
||||
#define LOG_DEBUG(fmt, ...)
|
||||
#define LOG_INFO(fmt, ...)
|
||||
#define LOG_WARN(fmt, ...)
|
||||
#define LOG_ERR(fmt, ...)
|
||||
#define LOG(fmt, ...)
|
||||
#define ASSERT(x)
|
||||
#define SALOF_LOG_DEBUG(fmt, ...)
|
||||
#define SALOF_LOG_INFO(fmt, ...)
|
||||
#define SALOF_LOG_WARN(fmt, ...)
|
||||
#define SALOF_LOG_ERR(fmt, ...)
|
||||
#define SALOF_LOG_LOG(fmt, ...)
|
||||
#endif
|
||||
|
||||
#endif // !_SALOF_H_
|
||||
|
Reference in New Issue
Block a user